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

Commit 69d41c0

Browse files
Kenneth Ahn JensenRubenWillems
authored andcommitted
Removed unintended change to from.SourceControlData
Fixed bug where MultiSourceControl.GetModifications would leave the from.SourceControlData changed, so the following call to GetModifications would result in Modifications being erroneously reported.
1 parent 110f44a commit 69d41c0

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

project/UnitTests/Core/SourceControl/MultiSourceControlTest.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,47 @@ public void PassesIndividualSourceDataAndCombines()
225225
Assert.AreEqual("sc1", to.SourceControlData[1].Name, "SourceControlData[1].Name");
226226
}
227227

228+
[Test]
229+
public void GetModificationsRepeatedlyShouldReturnSameResult()
230+
{
231+
IntegrationResult from = IntegrationResultMother.CreateSuccessful(DateTime.Now);
232+
IntegrationResult to = IntegrationResultMother.CreateSuccessful(DateTime.Now.AddDays(10));
233+
234+
string scValue = null;
235+
List<NameValuePair> list = new List<NameValuePair>();
236+
237+
list.Add(new NameValuePair("name0", "first"));
238+
scValue = XmlConversionUtil.ConvertObjectToXml(list);
239+
from.SourceControlData.Add(new NameValuePair("sc0", scValue));
240+
list.Clear();
241+
242+
list.Add(new NameValuePair("name1", "first"));
243+
list.Add(new NameValuePair("name2", "first"));
244+
scValue = XmlConversionUtil.ConvertObjectToXml(list);
245+
from.SourceControlData.Add(new NameValuePair("sc1", scValue));
246+
list.Clear();
247+
248+
List<ISourceControl> sourceControls = new List<ISourceControl>();
249+
sourceControls.Add(new MockSourceControl());
250+
sourceControls.Add(new MockSourceControl());
251+
252+
MultiSourceControl multiSourceControl = new MultiSourceControl();
253+
multiSourceControl.SourceControls = sourceControls.ToArray();
254+
255+
//// EXECUTE
256+
try
257+
{
258+
ArrayList firstReturnedMods = new ArrayList(multiSourceControl.GetModifications(from, to));
259+
ArrayList secondReturnedMods = new ArrayList(multiSourceControl.GetModifications(from, to));
260+
ArrayList thirdReturnedMods = new ArrayList(multiSourceControl.GetModifications(from, to));
261+
262+
Assert.AreEqual(secondReturnedMods.Count, thirdReturnedMods.Count);
263+
} catch (Exception e)
264+
{
265+
Assert.Fail("GetModifications threw Exception:" + e.Message);
266+
}
267+
}
268+
228269
[Test]
229270
public void PassesIndividualSourceDataAndCombinesSingleSourceControl()
230271
{

project/core/sourcecontrol/MultiSourceControl.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ public override Modification[] GetModifications(IIntegrationResult from, IIntegr
189189
to.SourceControlData.Clear();
190190
to.SourceControlData.AddRange(finalSourceControlData);
191191

192+
// reset the from.SourceControlData to its original contents
193+
from.SourceControlData.Clear();
194+
from.SourceControlData.AddRange(originalSourceControlData);
195+
192196
var modArray = new Modification[modificationSet.Count];
193197
modificationSet.Keys.CopyTo(modArray, 0);
194198
return modArray;

0 commit comments

Comments
 (0)