Beispiel #1
0
            public void It_can_intercept_on_node_type()
            {
                var interceptor = new TypeInterceptor<int>(input => input + 1);
                var personA = new Person { NameField = "Gøran", WeightField = 70, AgeField = 20, AgeProperty = 20 };
                var personB = new Person { NameField = "Torkild", WeightField = 80, AgeField = 30, AgeProperty = 30 };

                var diff = Diff.ObjectValues(personA, personB, interceptor);

                Assert.AreEqual(4, diff.Table.Rows.Count());
                Assert.AreEqual("Gøran", diff.Table[0].LeftValue);
                Assert.AreEqual("Torkild", diff.Table[0].RightValue);
                Assert.AreEqual(21, diff.Table[1].LeftValue);
                Assert.AreEqual(31, diff.Table[1].RightValue);
                Assert.AreEqual(70, diff.Table[2].LeftValue);
                Assert.AreEqual(80, diff.Table[2].RightValue);
                Assert.AreEqual(21, diff.Table[3].LeftValue);
                Assert.AreEqual(31, diff.Table[3].RightValue);
            }
Beispiel #2
0
 /// <summary>
 /// Registers a new TypeInterceptor object with the Container
 /// </summary>
 /// <param name="interceptor"></param>
 public void RegisterInterceptor(TypeInterceptor interceptor)
 {
     addExpression(pluginGraph => pluginGraph.InterceptorLibrary.AddInterceptor(interceptor));
 }
Beispiel #3
0
            public void It_should_be_possible_to_intercept_lists()
            {
                var left = new Person();
                left.Children = new List<Person>();
                var right = new Person();
                right.Children = new List<Person>();

                var numberOfInterceptions = 0;
                var listInterceptor = new TypeInterceptor<IEnumerable<Person>>(input =>
                {
                    numberOfInterceptions++;
                    return input;
                });

                Diff.ObjectValues(left, right, listInterceptor);
                Assert.AreEqual(2, numberOfInterceptions);
            }
Beispiel #4
0
 /// <summary>
 /// Registers a new TypeInterceptor object with the Container
 /// </summary>
 /// <param name="interceptor"></param>
 public void RegisterInterceptor(TypeInterceptor interceptor)
 {
     alter = x => x.InterceptorLibrary.AddInterceptor(interceptor);
 }
Beispiel #5
0
 public void AddInterceptor(TypeInterceptor interceptor)
 {
     _interceptors.Add(interceptor);
 }
 public void AddInterceptor(TypeInterceptor interceptor)
 {
     _interceptors.Add(interceptor);
 }