예제 #1
0
        public void ExceptionRaise_ForDiffOfDisparateFields()
        {
            var oldFieldName = "Test.OldMethod";
            var oldField = new Mock<IMethodData>();
            oldField.SetupGet(x => x.MethodSignature)
                .Returns(oldFieldName);

            var newFieldName = "Test.NewField";
            var newField = new Mock<IMethodData>();
            newField.SetupGet(x => x.MethodSignature)
                .Returns(newFieldName);

            var SUT = new MethodDiff(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<IMethodData>();
            oldField.SetupGet(x => x.AttributeData)
                .Returns(new List<IAttributeData>());

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

            var SUT = new MethodDiff(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<IMethodData>();
            oldField.SetupGet(x => x.AttributeData)
                .Returns(new List<IAttributeData>()
                {
                    unchangedAttribute.Object
                });

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

            var SUT = new MethodDiff(oldField.Object, newField.Object);
            Assert.False(SUT.HasChanged);
        }
예제 #4
0
 private void GetAddedAndRemovedMethods(IEnumTypeData beforeEnum, IEnumTypeData afterEnum)
 {
     foreach (var oldMethod in beforeEnum.MethodData)
     {
         if (afterEnum.MethodData.All(x => x.MethodSignature != oldMethod.MethodSignature))
         {
             RemovedMethods.Add(oldMethod);
             HasChanged = true;
         }
     }
     foreach (var newMethod in afterEnum.MethodData)
     {
         if (beforeEnum.MethodData.All(x => x.MethodSignature != newMethod.MethodSignature))
         {
             AddedMethods.Add(newMethod);
             HasChanged = true;
         }
     }
     foreach (var oldMethod in beforeEnum.MethodData)
     {
         var matchingNewField = afterEnum.MethodData.FirstOrDefault(
             x => x.MethodSignature == oldMethod.MethodSignature);
         if (matchingNewField != null)
         {
             var diff = new MethodDiff(oldMethod, matchingNewField);
             if (!diff.HasChanged)
             {
                 continue;
             }
             ModifiedMethods.Add(diff);
             HasChanged = true;
         }
     }
 }
예제 #5
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<IMethodData>();
            oldField.SetupGet(x => x.AttributeData)
                .Returns(new List<IAttributeData>()
                {
                    oldAttribute.Object
                });

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

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