|
1 | 1 | using System;
|
2 | 2 | using System.Collections;
|
| 3 | +using System.Collections.Generic; |
3 | 4 | using Exortech.NetReflector;
|
4 | 5 | using NMock;
|
5 | 6 | using NUnit.Framework;
|
6 | 7 | using ThoughtWorks.CruiseControl.Core;
|
7 | 8 | using ThoughtWorks.CruiseControl.Core.Sourcecontrol;
|
| 9 | +using ThoughtWorks.CruiseControl.Remote; |
8 | 10 |
|
9 | 11 | namespace ThoughtWorks.CruiseControl.UnitTests.Core.Sourcecontrol
|
10 | 12 | {
|
@@ -136,6 +138,68 @@ private DynamicMock CreateModificationsSourceControlMock(Modification[] mods, In
|
136 | 138 | return mock;
|
137 | 139 | }
|
138 | 140 |
|
| 141 | + private class MockSourceControl : ISourceControl |
| 142 | + { |
| 143 | + public Modification[] GetModifications(IIntegrationResult from, IIntegrationResult to) |
| 144 | + { |
| 145 | + Assert.AreEqual("first", from.SourceControlData[0].Value, "SourceControlData[0].Value"); |
| 146 | + |
| 147 | + to.SourceControlData.Clear(); |
| 148 | + to.SourceControlData.Add(from.SourceControlData[0]); |
| 149 | + |
| 150 | + return new Modification[] { }; |
| 151 | + } |
| 152 | + |
| 153 | + public void LabelSourceControl(IIntegrationResult result) { } |
| 154 | + public void GetSource(IIntegrationResult result) { } |
| 155 | + public void Initialize(IProject project) { } |
| 156 | + public void Purge(IProject project) { } |
| 157 | + } |
| 158 | + |
| 159 | + |
| 160 | + [Test] |
| 161 | + public void PassesIndividualSourceDataAndCombines() |
| 162 | + { |
| 163 | + IntegrationResult from = IntegrationResultMother.CreateSuccessful(DateTime.Now); |
| 164 | + IntegrationResult to = IntegrationResultMother.CreateSuccessful(DateTime.Now.AddDays(10)); |
| 165 | + |
| 166 | + string scValue = null; |
| 167 | + List<NameValuePair> list = new List<NameValuePair>(); |
| 168 | + |
| 169 | + list.Add(new NameValuePair("name0", "first")); |
| 170 | + scValue = XmlConversionUtil.ConvertObjectToXml(list); |
| 171 | + from.SourceControlData.Add(new NameValuePair("sc0", scValue)); |
| 172 | + list.Clear(); |
| 173 | + |
| 174 | + list.Add(new NameValuePair("name1", "first")); |
| 175 | + list.Add(new NameValuePair("name2", "first")); |
| 176 | + scValue = XmlConversionUtil.ConvertObjectToXml(list); |
| 177 | + from.SourceControlData.Add(new NameValuePair("sc1", scValue)); |
| 178 | + list.Clear(); |
| 179 | + |
| 180 | + List<ISourceControl> sourceControls = new List<ISourceControl>(); |
| 181 | + sourceControls.Add(new MockSourceControl()); |
| 182 | + sourceControls.Add(new MockSourceControl()); |
| 183 | + |
| 184 | + MultiSourceControl multiSourceControl = new MultiSourceControl(); |
| 185 | + multiSourceControl.SourceControls = sourceControls.ToArray(); |
| 186 | + |
| 187 | + //// EXECUTE |
| 188 | + ArrayList returnedMods = new ArrayList(multiSourceControl.GetModifications(from, to)); |
| 189 | + |
| 190 | + //// VERIFY |
| 191 | + Assert.AreEqual(from.SourceControlData.Count, to.SourceControlData.Count, "SourceControlData.Count"); |
| 192 | + |
| 193 | + list.Add(new NameValuePair("name0", "first")); |
| 194 | + Assert.AreEqual(XmlConversionUtil.ConvertObjectToXml(list), to.SourceControlData[0].Value, "SourceControlData[0].Value"); |
| 195 | + list.Clear(); |
| 196 | + Assert.AreEqual("sc0", to.SourceControlData[0].Name, "SourceControlData[0].Name"); |
| 197 | + |
| 198 | + list.Add(new NameValuePair("name1", "first")); |
| 199 | + Assert.AreEqual(XmlConversionUtil.ConvertObjectToXml(list), to.SourceControlData[1].Value, "SourceControlData[1].Value"); |
| 200 | + list.Clear(); |
| 201 | + Assert.AreEqual("sc1", to.SourceControlData[1].Name, "SourceControlData[1].Name"); |
| 202 | + } |
139 | 203 |
|
140 | 204 | [Test]
|
141 | 205 | public void IfRequireChangesFromAllTrueAndAllSourceControlHasModificationsThenReturnMods()
|
|
0 commit comments