Пример #1
0
        public void ExceptionRaise_ForDiffOfDisparateFields()
        {
            var oldFieldName = "Test.OldConstructor";
            var oldField = new Mock<IConstructorData>();
            oldField.SetupGet(x => x.ConstructorSignature)
                .Returns(oldFieldName);

            var newFieldName = "Test.NewConstructor";
            var newField = new Mock<IConstructorData>();
            newField.SetupGet(x => x.ConstructorSignature)
                .Returns(newFieldName);

            var SUT = new ConstructorDiff(oldField.Object, newField.Object);
        }
Пример #2
0
        public void AddedAttributes_Populated_ForNewAttribute()
        {
            var newAttributeName = "Test.NewAttribute";
            var newAttribute = new Mock<IAttributeData>();
            newAttribute.SetupGet(x => x.Name).Returns(newAttributeName);

            var oldField = new Mock<IConstructorData>();
            oldField.SetupGet(x => x.AttributeData)
                .Returns(new List<IAttributeData>());

            var newField = new Mock<IConstructorData>();
            newField.SetupGet(x => x.AttributeData)
                .Returns(new List<IAttributeData>()
                {
                    newAttribute.Object
                });

            var SUT = new ConstructorDiff(oldField.Object, newField.Object);
            Assert.True(SUT.AddedAttributes.Any(x => x.Name == newAttributeName));
            Assert.False(SUT.RemovedAttributes.Any());
        }
Пример #3
0
        public void HasChanged_IsNotSet_ForUnChangedField()
        {
            var unchangedAttributeName = "Test.SameAttribute";
            var unchangedAttribute = new Mock<IAttributeData>();
            unchangedAttribute.SetupGet(x => x.Name).Returns(unchangedAttributeName);

            var oldField = new Mock<IConstructorData>();
            oldField.SetupGet(x => x.AttributeData)
                .Returns(new List<IAttributeData>()
                {
                    unchangedAttribute.Object
                });

            var newField = new Mock<IConstructorData>();
            newField.SetupGet(x => x.AttributeData)
                .Returns(new List<IAttributeData>()
                {
                    unchangedAttribute.Object
                });

            var SUT = new ConstructorDiff(oldField.Object, newField.Object);
            Assert.False(SUT.HasChanged);
        }
Пример #4
0
        public void HasChanged_IsSet_ForChangedField()
        {
            var oldAttributeName = "Test.OldAttribute";
            var oldAttribute = new Mock<IAttributeData>();
            oldAttribute.SetupGet(x => x.Name).Returns(oldAttributeName);

            var newAttributeName = "Test.NewAttribute";
            var newAttribute = new Mock<IAttributeData>();
            newAttribute.SetupGet(x => x.Name).Returns(newAttributeName);

            var oldField = new Mock<IConstructorData>();
            oldField.SetupGet(x => x.AttributeData)
                .Returns(new List<IAttributeData>()
                {
                    oldAttribute.Object
                });

            var newField = new Mock<IConstructorData>();
            newField.SetupGet(x => x.AttributeData)
                .Returns(new List<IAttributeData>()
                {
                    newAttribute.Object
                });

            var SUT = new ConstructorDiff(oldField.Object, newField.Object);
            Assert.True(SUT.HasChanged);
        }