Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Commit 110f44a

Browse files
DanielRoseRubenWillems
authored andcommitted
Fixes ArgumentNullException with MultiSourceControl and svn (Bug #304)
1 parent 004a313 commit 110f44a

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

project/Remote/XmlConversionUtil.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ public static object ConvertXmlToObject(Type messageType, string message)
130130
/// <returns>true if the message can be deserialized to the given message type.</returns>
131131
public static bool CanConvertXmlToObject(Type messageType, string message)
132132
{
133+
if (string.IsNullOrEmpty(message))
134+
{
135+
return false;
136+
}
137+
133138
// Make sure the serialiser has been loaded
134139
if (!messageSerialisers.ContainsKey(messageType))
135140
{

project/UnitTests/Core/SourceControl/MultiSourceControlTest.cs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,8 @@ private class MockSourceControl : ISourceControl
142142
{
143143
public Modification[] GetModifications(IIntegrationResult from, IIntegrationResult to)
144144
{
145-
Assert.AreEqual("first", from.SourceControlData[0].Value, "SourceControlData[0].Value");
146-
147145
to.SourceControlData.Clear();
148-
to.SourceControlData.Add(from.SourceControlData[0]);
146+
to.SourceControlData.AddRange(from.SourceControlData);
149147

150148
return new Modification[] { };
151149
}
@@ -155,7 +153,32 @@ public void GetSource(IIntegrationResult result) { }
155153
public void Initialize(IProject project) { }
156154
public void Purge(IProject project) { }
157155
}
156+
157+
[Test]
158+
public void HandlesNullSourceControlDataValue()
159+
{
160+
var from = IntegrationResultMother.CreateSuccessful(DateTime.Now);
161+
var to = IntegrationResultMother.CreateSuccessful(DateTime.Now.AddDays(10));
162+
163+
from.SourceControlData.Add(new NameValuePair("SVN:LastRevision:svn://myserver/mypath", null));
164+
165+
var sourceControls = new List<ISourceControl> { new MockSourceControl(), new MockSourceControl() };
166+
var multiSourceControl = new MultiSourceControl { SourceControls = sourceControls.ToArray() };
167+
168+
//// EXECUTE
169+
var returnedMods = new ArrayList(multiSourceControl.GetModifications(from, to));
170+
171+
//// VERIFY
172+
Assert.AreEqual(0, returnedMods.Count, "SourceControlData.Count");
173+
174+
Assert.AreEqual(2, to.SourceControlData.Count, "SourceControlData.Count");
175+
176+
Assert.AreEqual("<ArrayOfNameValuePair />", to.SourceControlData[0].Value, "SourceControlData[0].Value");
177+
Assert.AreEqual("sc0", to.SourceControlData[0].Name, "SourceControlData[0].Name");
158178

179+
Assert.AreEqual("<ArrayOfNameValuePair><NameValuePair name=\"SVN:LastRevision:svn://myserver/mypath\" /></ArrayOfNameValuePair>", to.SourceControlData[1].Value, "SourceControlData[1].Value");
180+
Assert.AreEqual("sc1", to.SourceControlData[1].Name, "SourceControlData[1].Name");
181+
}
159182

160183
[Test]
161184
public void PassesIndividualSourceDataAndCombines()
@@ -196,6 +219,7 @@ public void PassesIndividualSourceDataAndCombines()
196219
Assert.AreEqual("sc0", to.SourceControlData[0].Name, "SourceControlData[0].Name");
197220

198221
list.Add(new NameValuePair("name1", "first"));
222+
list.Add(new NameValuePair("name2", "first"));
199223
Assert.AreEqual(XmlConversionUtil.ConvertObjectToXml(list), to.SourceControlData[1].Value, "SourceControlData[1].Value");
200224
list.Clear();
201225
Assert.AreEqual("sc1", to.SourceControlData[1].Name, "SourceControlData[1].Name");

0 commit comments

Comments
 (0)