예제 #1
0
        public void IgnoreTypesTest()
        {
            ExampleDto1 dto1 = new ExampleDto1();

            dto1.Name = "Greg";

            ExampleDto2 dto2 = new ExampleDto2();

            dto2.Name = "Greg";

            ComparisonResult result = _compare.Compare(dto1, dto2);

            //These will be different because the types are different
            Assert.IsFalse(result.AreEqual);
            Console.WriteLine(result.DifferencesString);

            _compare.Config.IgnoreObjectTypes = true;

            result = _compare.Compare(dto1, dto2);

            //Ignore types so they will be equal
            Assert.IsTrue(result.AreEqual);

            _compare.Config.Reset();
        }
예제 #2
0
            public void ExpectedHasDifferentEnumerationThanActual_AssertFails()
            {
                object expected = new ExampleDto1 {ListOfStrings = new[] {"Foo"}};
                object actual = new ExampleDto2 {ListOfStrings = new[] {"Bar"}};

                //Act
                bool assertFailed = false;
                try
                {
                    DtoAssert.AreEqual(expected, actual);
                }
                catch (AssertFailedException)
                {
                    assertFailed = true;
                }

                //Assert
                Assert.IsTrue(assertFailed);
            }
예제 #3
0
            public void ExpectedNotSameTypeAsActual_AssertFails()
            {
                //Arrange
                object expected = new ExampleDto1 {StringValue = "example", DoubleValue = 1.0, IntValue = 2,};
                object actual = new ExampleDto2 {StringValue = "example", DoubleValue = 1.0, IntValue = 2,};

                //Act
                bool assertFailed = false;
                try
                {
                    DtoAssert.AreEqual(expected, actual);
                }
                catch (AssertFailedException)
                {
                    assertFailed = true;
                }

                //Assert
                Assert.IsTrue(assertFailed);
            }