Exemplo n.º 1
0
        public void INTARRAY_values_are_NOT_similar_test()
        {
            var first  = new int[] { 101, 102 };
            var second = new int[] { 103, 101 };

            Assert.IsFalse(Comparer.AreSimilar(first, second));
        }
        public void ComplexType__same_values()
        {
            Student One = new Student
            {
                Marks   = new[] { 80, 90, 100 },
                Id      = 1,
                Name    = "MrX",
                Address = new Address()
                {
                    Country = "India",
                    Cities  = new[] { "Pune", "Noida" }
                }
            };

            Student Two = new Student
            {
                Marks   = new[] { 80, 90, 100 },
                Id      = 1,
                Name    = "MrX",
                Address = new Address()
                {
                    Country = "India",
                    Cities  = new[] { "Pune", "Noida" }
                }
            };

            Assert.IsTrue(Comparer.AreSimilar(One, Two));
        }
Exemplo n.º 3
0
        public void Students_are_not_similar_InDictionary()
        {
            var a = new Student
            {
                Name  = "John",
                Id    = 100,
                Marks = new[] { 80, 90, 100 }
            };

            var b = new Student
            {
                Name  = "John",
                Id    = 101,
                Marks = new[] { 90, 80, 100 }
            };
            var StudentDictionaryA
                = new Dictionary <int, Student>();

            StudentDictionaryA.Add(a.Id, a);

            var StudentDictionaryB
                = new Dictionary <int, Student>();

            StudentDictionaryB.Add(b.Id, b);

            Assert.IsFalse(Comparer.AreSimilar(StudentDictionaryA, StudentDictionaryB));
        }
Exemplo n.º 4
0
        public void STRINGARRAY_values_are_NOT_similar_test()
        {
            var first  = new string[] { "A", "B" };
            var second = new string[] { "C", "A" };

            Assert.IsFalse(Comparer.AreSimilar(first, second));
        }
Exemplo n.º 5
0
        public void Null_values_are_similar_test()
        {
            string string1 = null, string2 = null;
            var    result = Comparer.AreSimilar(string1, string2);

            Assert.AreEqual(StandardCode.SUCCESS, result);
        }
        public void Objects_are_not_equal_test()
        {
            Student student1 = new Student()
            {
                Id         = 100,
                Average    = 10.01,
                IsActive   = true,
                Grade      = 'B',
                Percentage = 76.01F,
                Name       = "John",
                Marks      = new[] { 60, 70, 80 },
                Subjects   = new List <string> {
                    "C", "Java", "Python"
                }
            };
            Student student2 = new Student()
            {
                Id         = 100,
                Average    = 10.01,
                IsActive   = true,
                Grade      = 'B',
                Percentage = 76.01F,
                Name       = "John",
                Marks      = new[] { 80, 90, 70 },
                Subjects   = new List <string> {
                    "C", "Java", "Python"
                }
            };

            Assert.IsFalse(Comparer.AreSimilar(student1, student2));
        }
        public void Object_list_are_similar_fail()
        {
            List <Student> students1 = new List <Student>()
            {
                new Student()
                {
                    Id = 1, Name = "first", Marks = new int[] { 80, 75, 70 }
                },
                new Student()
                {
                    Id = 2, Name = "second", Marks = new int[] { 80, 85 }
                }
            };

            List <Student> students2 = new List <Student>()
            {
                new Student()
                {
                    Id = 1, Name = "first", Marks = new int[] { 80, 75, 70 }
                },
                new Student()
                {
                    Id = 2, Name = "second", Marks = new int[] { 80, 85, 60 }
                }
            };

            Assert.IsFalse(Comparer.AreSimilar(students1, students2));
        }
 public void Primitive_values_are_similar_test()
 {
     Assert.IsTrue(Comparer.AreSimilar(1, 1));
     Assert.IsFalse(Comparer.AreSimilar(1, 2));
     Assert.IsTrue(Comparer.AreSimilar(1, 1.0));
     Assert.IsTrue(Comparer.AreSimilar("John", "John"));
 }
 public void Primitive_list_are_similar_test()
 {
     Assert.IsTrue(Comparer.AreSimilar(new List <int> {
         1, 2, 3, 4
     }, new List <int> {
         2, 1, 3, 4
     }));
     Assert.IsFalse(Comparer.AreSimilar(new List <int> {
         1, 2, 3, 4
     }, new List <int> {
         1, 7, 3, 4
     }));
     Assert.IsTrue(Comparer.AreSimilar(new List <char> {
         'a', 'b', 'c'
     }, new List <char> {
         'a', 'c', 'b'
     }));
     Assert.IsFalse(Comparer.AreSimilar(new List <char> {
         'a', 'b', 'c'
     }, new List <char> {
         'a', 'd', 'c'
     }));
     Assert.IsTrue(Comparer.AreSimilar(new List <string> {
         "one", "two", "three"
     }, new List <string> {
         "three", "two", "one"
     }));
     Assert.IsFalse(Comparer.AreSimilar(new List <string> {
         "one", "two", "three"
     }, new List <string> {
         "three", "two", "zero"
     }));
 }
        public void NullValue_Equality()
        {
            string first = null, second = null;
            var    isEqual = Comparer.AreSimilar(first, second);

            Assert.IsTrue(isEqual);
        }
Exemplo n.º 11
0
        public void Empty_objects_are_similar_test()
        {
            Student student1 = new Student();
            Student student2 = new Student();

            Assert.IsTrue(Comparer.AreSimilar(student1, student2));
        }
Exemplo n.º 12
0
        public void Valuestring_Nullstring_values_are_not_similar_test()
        {
            string first = "ABCD", second = null;
            bool   result = Comparer.AreSimilar(first, second);

            Assert.AreEqual(false, result);
        }
Exemplo n.º 13
0
        public void different_objects_are_not_similar_test()
        {
            object test1 = 1;
            object test2 = "test";

            Assert.IsFalse(Comparer.AreSimilar(test1, test2));
        }
Exemplo n.º 14
0
 public void Object_values_are_similar_test()
 {
     Assert.IsFalse(Comparer.AreSimilar(s1, s2));
     Assert.IsTrue(Comparer.AreSimilar(s1, s3));
     Assert.IsTrue(Comparer.AreSimilar(studentS1, studentS2));
     Assert.IsTrue(Comparer.AreSimilar(strings1, strings2));
 }
Exemplo n.º 15
0
        public void string_with_different_values_are_not_similar_test()
        {
            string first  = "test1";
            string second = "test2";

            Assert.IsFalse(Comparer.AreSimilar(first, second));
        }
Exemplo n.º 16
0
        public void int_values_are_similar_test()
        {
            int first = 8, second = 8, third = 9;

            Assert.IsTrue(Comparer.AreSimilar(first, second));
            Assert.IsFalse(Comparer.AreSimilar(first, third));
        }
Exemplo n.º 17
0
        public void string_values_are_similar_test()
        {
            string first = "Roger", second = "Roger", third = "John";

            Assert.IsTrue(Comparer.AreSimilar(first, second));
            Assert.IsFalse(Comparer.AreSimilar(first, third));
        }
        public void NullValue_InEquality()
        {
            string first = null, second = "arvind";
            var    isEqual = Comparer.AreSimilar(first, second);

            Assert.IsFalse(isEqual);
        }
Exemplo n.º 19
0
        public void Null_values_are_similar_test()
        {
            string first  = null;
            string second = null;

            Assert.IsTrue(Comparer.AreSimilar(first, second));
        }
Exemplo n.º 20
0
        public void Premitive_values_are_similar_test()
        {
            float first  = 5.2f,
                  second = 5.2f;

            Assert.IsTrue(Comparer.AreSimilar(first, second));
        }
Exemplo n.º 21
0
        public void ClassObjArray_values_are_similar_test()
        {
            SubjectGradesstr[] first = null,
            second = null;

            Assert.IsTrue(Comparer.AreSimilar(first, second));

            first  = new SubjectGradesstr[] { };
            second = new SubjectGradesstr[] { };

            Assert.IsTrue(Comparer.AreSimilar(first, second));

            first = new SubjectGradesstr[] { new SubjectGradesstr {
                                                 Grade = "A"
                                             }, new SubjectGradesstr {
                                                 Grade = "B"
                                             }, null };
            second = new SubjectGradesstr[] { new SubjectGradesstr {
                                                  Grade = "A"
                                              }, new SubjectGradesstr {
                                                  Grade = "B"
                                              }, null };

            Assert.IsTrue(Comparer.AreSimilar(first, second));
        }
Exemplo n.º 22
0
        public void Object_with_list_Not_similar_test()
        {
            var s1 = new Student()
            {
                Id    = 101,
                Name  = "Mahesh",
                Codes = new string[] { "MH", "IN" },
                Marks = new List <int>()
                {
                    1, 2, 3, 4, 5, 6, 7, 8, 9, 10
                }
            };
            var s2 = new Student()
            {
                Id    = 101,
                Name  = "Santosh",
                Codes = new string[] { "MH", "IN" },
                Marks = new List <int>()
                {
                    1, 2, 3, 4, 5, 6, 7, 8, 9, 10
                }
            };

            Assert.IsFalse(Comparer.AreSimilar(s1, s2));
        }
        public void NestedEnumerableOfClass_InEquality()
        {
            var a1 = new ClassA
            {
                EnumerableOfB = new List <ClassB>
                {
                    new ClassB
                    {
                        Property1 = "A"
                    },
                    new ClassB
                    {
                        Property1 = "C"
                    }
                }
            };
            var a2 = new ClassA
            {
                EnumerableOfB = new List <ClassB>
                {
                    new ClassB
                    {
                        Property1 = "A"
                    }
                }
            };
            var isEqual = Comparer.AreSimilar(a1, a2);

            Assert.IsFalse(isEqual);
        }
Exemplo n.º 24
0
        public void int_with_different_values_are_not_similar_test()
        {
            int first  = 1;
            int second = 2;

            Assert.IsFalse(Comparer.AreSimilar(first, second));
        }
        public void Array_values_are_non_similar_test()
        {
            var first  = new[] { 1, 2, 3 };
            var second = new[] { 1, 2 };

            Assert.IsFalse(Comparer.AreSimilar(first, second));
        }
        public void String_Inequality()
        {
            var a1      = new ClassA("Arvind");
            var a2      = new ClassA("Vaibhav");
            var isEqual = Comparer.AreSimilar(a1, a2);

            Assert.IsFalse(isEqual);
        }
        public void String_Equality()
        {
            var a1      = new ClassA("Arvind");
            var a2      = new ClassA("Arvind");
            var isEqual = Comparer.AreSimilar(a1, a2);

            Assert.IsTrue(isEqual);
        }
        public void Int_Inequality()
        {
            var a1      = new ClassA(10);
            var a2      = new ClassA(8);
            var isEqual = Comparer.AreSimilar(a1, a2);

            Assert.IsFalse(isEqual);
        }
        public void Int_Equality()
        {
            var a1      = new ClassA(9);
            var a2      = new ClassA(9);
            var isEqual = Comparer.AreSimilar(a1, a2);

            Assert.IsTrue(isEqual);
        }
        public void IntArray_InEquality()
        {
            var a1      = new ClassA(new int[] { 1, 4, 3 });
            var a2      = new ClassA(new int[] { 1, 3, 5, 7 });
            var isEqual = Comparer.AreSimilar(a1, a2);

            Assert.IsFalse(isEqual);
        }