public void Insert_InMiddlePosition_ShouldAddItemInFifthPosition() { string inputValue = "<PropertyGroup></PropertyGroup>"; MsBuildXmlPropertyGroupImplementation propertyGroupImplementation = new MsBuildXmlPropertyGroupImplementation(CreateFromString(inputValue)); for (int i = 0; i <= 10; i++) { Mock <IMsBuildProperty> mock = new Mock <IMsBuildProperty>(); mock.Setup(m => m.Value).Returns($"OverwrittenContent{i}"); mock.Setup(m => m.Name).Returns($"OverwrittenTest{i}"); propertyGroupImplementation.Add(mock.Object); } Mock <IMsBuildProperty> mockInsert = new Mock <IMsBuildProperty>(); mockInsert.Setup(m => m.Value).Returns($"OverwrittenContent99"); mockInsert.Setup(m => m.Name).Returns($"OverwrittenTest99"); propertyGroupImplementation.Insert(5, mockInsert.Object); Assert.AreEqual("OverwrittenContent99", propertyGroupImplementation[5].Value); }
public void Add_WithOneProperty_ShouldAddItemToList() { string inputValue = "<PropertyGroup></PropertyGroup>"; MsBuildXmlPropertyGroupImplementation propertyGroupImplementation = new MsBuildXmlPropertyGroupImplementation(CreateFromString(inputValue)); Mock <IMsBuildProperty> mock = new Mock <IMsBuildProperty>(); mock.Setup(m => m.Value).Returns("OverwrittenContent"); mock.Setup(m => m.Name).Returns("OverwrittenTest"); propertyGroupImplementation.Add(mock.Object); Assert.AreEqual("OverwrittenContent", propertyGroupImplementation[0].Value); }
public void IndexOf_LastEntryOfTenItems_ShouldReturnValueTen() { string inputValue = "<PropertyGroup></PropertyGroup>"; MsBuildXmlPropertyGroupImplementation propertyGroupImplementation = new MsBuildXmlPropertyGroupImplementation(CreateFromString(inputValue)); for (int i = 0; i <= 10; i++) { Mock <IMsBuildProperty> mock = new Mock <IMsBuildProperty>(); mock.Setup(m => m.Value).Returns($"OverwrittenContent{i}"); mock.Setup(m => m.Name).Returns($"OverwrittenTest{i}"); propertyGroupImplementation.Add(mock.Object); } Assert.AreEqual(10, propertyGroupImplementation.IndexOf(propertyGroupImplementation.Last())); }
public void Remove_FirstEntry_ShouldRemoveFirstEntry() { string inputValue = "<PropertyGroup></PropertyGroup>"; MsBuildXmlPropertyGroupImplementation propertyGroupImplementation = new MsBuildXmlPropertyGroupImplementation(CreateFromString(inputValue)); for (int i = 1; i < 10; i++) { Mock <IMsBuildProperty> mock = new Mock <IMsBuildProperty>(); mock.Setup(m => m.Value).Returns($"OverwrittenContent{i}"); mock.Setup(m => m.Name).Returns($"OverwrittenTest{i}"); propertyGroupImplementation.Add(mock.Object); } propertyGroupImplementation.Remove(propertyGroupImplementation[0]); Assert.AreEqual("OverwrittenContent2", propertyGroupImplementation[0].Value); }
public void CopyTo_Array_ShouldCopyAllValuesToArray() { string inputValue = "<PropertyGroup></PropertyGroup>"; IMsBuildProperty[] array = new IMsBuildProperty[20]; MsBuildXmlPropertyGroupImplementation propertyGroupImplementation = new MsBuildXmlPropertyGroupImplementation(CreateFromString(inputValue)); for (int i = 0; i <= 10; i++) { Mock <IMsBuildProperty> mock = new Mock <IMsBuildProperty>(); mock.Setup(m => m.Value).Returns($"OverwrittenContent{i}"); mock.Setup(m => m.Name).Returns($"OverwrittenTest{i}"); propertyGroupImplementation.Add(mock.Object); } propertyGroupImplementation.CopyTo(array, 0); Assert.AreEqual("OverwrittenContent0", array[0].Value); }