Esempio n. 1
0
        public void Write()
        {
            var o = new TestObject3();

            TypeAccessor.WriteConsole(o);
            TypeAccessor.WriteDebug(o);
        }
Esempio n. 2
0
        public void ComplexTypeWithArrayProperties()
        {
            var obj1 = new TestObject3
              {
            List = new[]
            {
              new TestObject2 { PropX = "xyz", PropY = new TestObject1 { Prop1 = "abc", Prop2 = 123 } },
              new TestObject2 { PropX = "xyz", PropY = new TestObject1 { Prop1 = "abc", Prop2 = 123 } },
            }
              };
              var obj2 = new TestObject3
              {
            List = new[]
            {
              new TestObject2 { PropX = "abc", PropY = new TestObject1 { Prop1 = "x1", Prop2 = 123 } },
              new TestObject2 { PropX = "def", PropY = new TestObject1 { Prop1 = "x2", Prop2 = 456 } },
              new TestObject2 { PropX = "ghi", PropY = new TestObject1 { Prop1 = "x3", Prop2 = 789 } },
            }
              };
              var sut = new ObjectComparer();

              var result = sut.Compare(obj1, obj2).ToList();

              Assert.AreEqual(10, result.Count());
              CheckComparison(result[0], ComparisonResult.NotEqual, ".List.Length", 2, 3);
              CheckComparison(result[1], ComparisonResult.NotEqual, ".List[0].PropX", "xyz", "abc");
              CheckComparison(result[2], ComparisonResult.NotEqual, ".List[0].PropY.Prop1", "abc", "x1");
              CheckComparison(result[3], ComparisonResult.Equal, ".List[0].PropY.Prop2", 123, 123);
              CheckComparison(result[4], ComparisonResult.NotEqual, ".List[1].PropX", "xyz", "def");
              CheckComparison(result[5], ComparisonResult.NotEqual, ".List[1].PropY.Prop1", "abc", "x2");
              CheckComparison(result[6], ComparisonResult.NotEqual, ".List[1].PropY.Prop2", 123, 456);
              CheckComparison(result[7], ComparisonResult.NotEqual, ".List[2].PropX", null, "ghi");
              CheckComparison(result[8], ComparisonResult.NotEqual, ".List[2].PropY.Prop1", null, "x3");
              CheckComparison(result[9], ComparisonResult.NotEqual, ".List[2].PropY.Prop2", null, 789);
        }
Esempio n. 3
0
    void Test3()
    {
        string      jsonString     = "{\"success\":[false,false,false,true],\"hoursSpent\":[15,20],\"author\":[]}";
        TestObject3 expectedResult = new TestObject3(new bool[] { false, false, false, true }, new int[] { 15, 20 }, new string[] {});

        TestObject3 obj = JsonParser.FromJson <TestObject3>(jsonString);

        if (expectedResult.Equals(obj))
        {
            Debug.Log("Reader Test 3 : Success");
        }
        else
        {
            Debug.LogWarning("Reader Test 3 : Failure");
        }

        string json = JsonParser.ToJson <TestObject3>(obj);

        if (jsonString == json)
        {
            Debug.Log("Writer Test 3 : Success");
        }
        else
        {
            Debug.LogWarning(String.Format("Writer Test 3 : Failure : {0}", json));
        }
    }
Esempio n. 4
0
        public void Test3()
        {
            SourceObject so = new SourceObject();
            TestObject3  to = Map.ObjectToObject <TestObject3>(so);

            Assert.AreEqual(true, to.Value);
        }
Esempio n. 5
0
        public void AccessMember2()
        {
            var accessor = GetAccessor <TestObject3, int>("IntField");

            var obj = new TestObject3();

            Assert.AreEqual(obj.IntField, accessor(obj));
        }
Esempio n. 6
0
        public void AccessMember()
        {
            var ta  = TypeAccessor.GetAccessor <TestObject3>();
            var ma  = ta["IntField"];
            var obj = new TestObject3();
            var val = ma.GetInt32(obj);

            Assert.AreEqual(obj.IntField, val);
        }
        public void BulkOperationsTest()
        {
            var items = new List <TestObject3>();

            for (int i = 0; i < 14000; i++)
            {
                items.Add(new TestObject3
                {
                    Name = "Tst" + i,
                    Guid = Guid.NewGuid(),
                    P    = i
                });
            }

            using (var repo = _scope.Resolve <IRepository <TestObject3> >())
            {
                repo.StoreBulk(items);
            }

            using (var repo = _scope.Resolve <IRepository <TestObject3> >())
            {
                Assert.AreEqual(items.Count, repo.GetAll().Count());
            }

            using (var repo = _scope.Resolve <IRepository <TestObject3> >())
            {
                var         rRepo = (BasicRavenRepository <TestObject3>)repo;
                TestObject3 obj   = null;
                var         cnt   = 0;
                foreach (var testObject3 in rRepo.Enumerate(q => q.Where(x => x.P != 0)))
                {
                    obj = testObject3;
                    if (obj != null)
                    {
                        cnt++;
                    }
                }
                Assert.AreEqual(items.Count - 1, cnt);
            }

            using (var repo = _scope.Resolve <IRepository <TestObject3> >())
            {
                TestObject3 obj = null;
                var         cnt = 0;
                foreach (var object3 in repo.Query)
                {
                    obj = object3;
                    if (obj != null)
                    {
                        cnt++;
                    }
                }
                Assert.AreEqual(128, cnt);
            }
        }
Esempio n. 8
0
        public void ComplexTypeWithArrayProperties()
        {
            var obj1 = new TestObject3
            {
                List = new[]
                {
                    new TestObject2 {
                        PropX = "xyz", PropY = new TestObject1 {
                            Prop1 = "abc", Prop2 = 123
                        }
                    },
                    new TestObject2 {
                        PropX = "xyz", PropY = new TestObject1 {
                            Prop1 = "abc", Prop2 = 123
                        }
                    },
                }
            };
            var obj2 = new TestObject3
            {
                List = new[]
                {
                    new TestObject2 {
                        PropX = "abc", PropY = new TestObject1 {
                            Prop1 = "x1", Prop2 = 123
                        }
                    },
                    new TestObject2 {
                        PropX = "def", PropY = new TestObject1 {
                            Prop1 = "x2", Prop2 = 456
                        }
                    },
                    new TestObject2 {
                        PropX = "ghi", PropY = new TestObject1 {
                            Prop1 = "x3", Prop2 = 789
                        }
                    },
                }
            };
            var sut = new ObjectComparer();

            var result = sut.Compare(obj1, obj2).ToList();

            Assert.AreEqual(10, result.Count());
            CheckComparison(result[0], ComparisonResult.NotEqual, ".List.Length", 2, 3);
            CheckComparison(result[1], ComparisonResult.NotEqual, ".List[0].PropX", "xyz", "abc");
            CheckComparison(result[2], ComparisonResult.NotEqual, ".List[0].PropY.Prop1", "abc", "x1");
            CheckComparison(result[3], ComparisonResult.Equal, ".List[0].PropY.Prop2", 123, 123);
            CheckComparison(result[4], ComparisonResult.NotEqual, ".List[1].PropX", "xyz", "def");
            CheckComparison(result[5], ComparisonResult.NotEqual, ".List[1].PropY.Prop1", "abc", "x2");
            CheckComparison(result[6], ComparisonResult.NotEqual, ".List[1].PropY.Prop2", 123, 456);
            CheckComparison(result[7], ComparisonResult.NotEqual, ".List[2].PropX", null, "ghi");
            CheckComparison(result[8], ComparisonResult.NotEqual, ".List[2].PropY.Prop1", null, "x3");
            CheckComparison(result[9], ComparisonResult.NotEqual, ".List[2].PropY.Prop2", null, 789);
        }
Esempio n. 9
0
        public void LazyInstancesTest()
        {
            TestObject3 o = (TestObject3)TypeAccessor.CreateInstance(typeof(TestObject3));

            Assert.AreEqual("", o.Str1);
            Assert.AreEqual("", o.Str2);

            o.Str1 = null;
            o.Str2 = null;

            Assert.AreEqual("", o.Str1);
            Assert.AreEqual(null, o.Str2);
        }
Esempio n. 10
0
        public void Test3()
        {
            TestObject3 o = (TestObject3)TypeAccessor.CreateInstance(typeof(TestObject3));

            Assert.AreEqual(20, o.Value);

            o = (TestObject3)TypeAccessor.CreateInstance(typeof(TestObject3), null);
            Assert.AreEqual(20, o.Value);

            InitContext ic = new InitContext();

            ic.Parameters = new object[] { 30 };
            o             = (TestObject3)TypeAccessor.CreateInstance(typeof(TestObject3), ic);
            Assert.AreEqual(30, o.Value);
        }
Esempio n. 11
0
        public void ReturnsEqualForStringProperty()
        {
            const string VALUE = "abc";

            var obj1 = new TestObject3 {
                Prop1 = VALUE
            };
            var obj2 = new TestObject3 {
                Prop1 = VALUE
            };
            var sut = new ObjectComparer();

            var result = sut.Compare(obj1, obj2).ToList();

            Assert.AreEqual(1, result.Count);
            CheckComparison(result[0], ComparisonResult.Equal, ".Prop1", VALUE, VALUE);
        }
Esempio n. 12
0
 public bool Equals(TestObject3 other)
 {
     if (this.success.Length != other.success.Length)
     {
         Debug.LogWarning("TestObject3 : Lengths of success does not match. Type bool[]");
         return(false);
     }
     if (this.hoursSpent.Length != other.hoursSpent.Length)
     {
         Debug.LogWarning("TestObject3 : Lengths of hoursSpent does not match. Type int[]");
         return(false);
     }
     if (this.author.Length != other.author.Length)
     {
         Debug.LogWarning("TestObject3 : Lengths of author does not match. Type string[]");
         return(false);
     }
     for (int i = 0; i < this.success.Length; i++)
     {
         if (this.success[i] != other.success[i])
         {
             Debug.LogWarning(String.Format("TestObject3 : Field success[{0}] does not match. Type bool[]", i));
             return(false);
         }
     }
     for (int i = 0; i < this.hoursSpent.Length; i++)
     {
         if (this.hoursSpent[i] != other.hoursSpent[i])
         {
             Debug.LogWarning(String.Format("TestObject3 : Field hoursSpent[{0}] does not match. Type int[]", i));
             return(false);
         }
     }
     for (int i = 0; i < this.author.Length; i++)
     {
         if (this.author[i] != other.author[i])
         {
             Debug.LogWarning(String.Format("TestObject3 : Field author[{0}] does not match. Type string[]", i));
             return(false);
         }
     }
     return(true);
 }
Esempio n. 13
0
        public void ReturnsNotEqualForStringProperty()
        {
            const string VALUE1 = "abc";
              const string VALUE2 = "def";

              var obj1 = new TestObject3 { Prop1 = VALUE1 };
              var obj2 = new TestObject3 { Prop1 = VALUE2 };
              var sut = new ObjectComparer();

              var result = sut.Compare(obj1, obj2).ToList();

              Assert.AreEqual(1, result.Count);
              CheckComparison(result[0], ComparisonResult.NotEqual, ".Prop1", VALUE1, VALUE2);
        }