当前位置: 首页>>代码示例>>C#>>正文


C# System.ShouldBeEquivalentTo方法代码示例

本文整理汇总了C#中System.ShouldBeEquivalentTo方法的典型用法代码示例。如果您正苦于以下问题:C# System.ShouldBeEquivalentTo方法的具体用法?C# System.ShouldBeEquivalentTo怎么用?C# System.ShouldBeEquivalentTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System的用法示例。


在下文中一共展示了System.ShouldBeEquivalentTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DateTime

        public void When_specific_properties_of_a_subject_are_compared_with_another_object_it_should_ignore_the_other_properties
            ()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var subject = new
            {
                Age = 36,
                Birthdate = new DateTime(1973, 9, 20),
                Name = "John"
            };

            var customer = new
            {
                Age = 36,
                Birthdate = new DateTime(1973, 9, 20),
                Name = "Dennis"
            };

            //-----------------------------------------------------------------------------------------------------------
            // Act 
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.ShouldBeEquivalentTo(customer, options => options
                .Including(d => d.Age)
                .Including(d => d.Birthdate));

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldNotThrow();
        }
开发者ID:uhaciogullari,项目名称:FluentAssertions.MonoTouch,代码行数:32,代码来源:EquivalencySpecs.cs

示例2: WriteState

        public void WriteState()
        {
            var converter = new StateBucketConverter();
            var buckets = new[]
            {
                new StateBucket("TestType1","123",new State(1,"SomeThingOrOther"), DateTime.Now.AddMinutes(-1)),
                new StateBucket("TestType2","124",new State(1,"Type 2 State"), DateTime.Now),
            };

            var state = converter.Convert(buckets);
            var restored = converter.Convert(state);
            buckets.ShouldBeEquivalentTo(restored);
        }
开发者ID:mgnslndh,项目名称:TailBlazer,代码行数:13,代码来源:StateBucketFixture.cs

示例3: Then_it_should_ignore_small_differences_without_the_need_of_local_options

            public void Then_it_should_ignore_small_differences_without_the_need_of_local_options()
            {
                var actual = new
                {
                    Value = (1D/3D)
                };

                var expected = new
                {
                    Value = 0.33D
                };

                Action act = () => actual.ShouldBeEquivalentTo(expected);

                act.ShouldNotThrow();
            }
开发者ID:leijiancd,项目名称:fluentassertions,代码行数:16,代码来源:AssertionOptionSpecs.cs

示例4: Then_this_should_not_throw

            public void Then_this_should_not_throw()
            {
                var subject = new
                {
                    Address = IPAddress.Parse("1.2.3.4"),
                    Word = "a"
                };

                var expected = new
                {
                    Address = IPAddress.Parse("1.2.3.4"),
                    Word = "a"
                };

                Action act = () => subject.ShouldBeEquivalentTo(expected,
                    options => options.ComparingByValue<IPAddress>());

                act.ShouldNotThrow();
            }
开发者ID:leijiancd,项目名称:fluentassertions,代码行数:19,代码来源:AssertionOptionSpecs.cs

示例5: When_an_assertion_is_overridden_for_a_predicate_it_should_use_the_provided_action

        public void When_an_assertion_is_overridden_for_a_predicate_it_should_use_the_provided_action()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var subject = new
            {
                Date = 14.July(2012).At(12, 59, 59)
            };

            var expectation = new
            {
                Date = 14.July(2012).At(13, 0, 0)
            };
            
            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.ShouldBeEquivalentTo(expectation, options => options
                .Using<DateTime>(ctx => ctx.Subject.Should().BeCloseTo(ctx.Expectation, 1000))
                .When(info => info.PropertyPath.EndsWith("Date")));

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldNotThrow();
        }        
开发者ID:uhaciogullari,项目名称:FluentAssertions.MonoTouch,代码行数:27,代码来源:EquivalencySpecs.cs

示例6: When_two_string_properties_do_not_match_it_should_throw_and_state_the_difference

        public void When_two_string_properties_do_not_match_it_should_throw_and_state_the_difference()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var subject = new
            {
                Name = "Dennes"
            };

            var other = new
            {
                Name = "Dennis"
            };

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.ShouldBeEquivalentTo(other, options => options.Including(d => d.Name));

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldThrow<AssertFailedException>().WithMessage(
                "Expected property Name to be \"Dennis\", but \"Dennes\" differs near \"es\" (index 4)", ComparisonMode.StartWith);
        }
开发者ID:uhaciogullari,项目名称:FluentAssertions.MonoTouch,代码行数:26,代码来源:EquivalencySpecs.cs

示例7: When_two_collection_properties_dont_match_it_should_throw_and_specify_the_difference

        public void When_two_collection_properties_dont_match_it_should_throw_and_specify_the_difference()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var subject = new
            {
                Values = new[]
                {
                    1, 2, 3
                }
            };

            var other = new
            {
                Values = new[]
                {
                    1, 4, 3
                }
            };

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.ShouldBeEquivalentTo(other);

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldThrow<AssertFailedException>().WithMessage(
                "Expected property Values[1] to be 4, but found 2", ComparisonMode.StartWith);
        }
开发者ID:uhaciogullari,项目名称:FluentAssertions.MonoTouch,代码行数:32,代码来源:EquivalencySpecs.cs

示例8: When_two_objects_have_the_same_properties_but_a_different_value_it_should_throw

        public void When_two_objects_have_the_same_properties_but_a_different_value_it_should_throw()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var subject = new
            {
                Age = 36,
            };

            var expectation = new
            {
                Age = 37,
            };

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.ShouldBeEquivalentTo(expectation, "because {0} are the same", "they");

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldThrow<AssertFailedException>().WithMessage(
                "Expected property Age to be 37 because they are the same, but found 36", ComparisonMode.StartWith);
        }
开发者ID:uhaciogullari,项目名称:FluentAssertions.MonoTouch,代码行数:26,代码来源:EquivalencySpecs.cs

示例9: When_equally_named_properties_are_type_incompatiblle_it_should_throw

        public void When_equally_named_properties_are_type_incompatiblle_it_should_throw()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var subject = new
            {
                Type = "A",
            };

            var other = new
            {
                Type = 36,
            };

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.ShouldBeEquivalentTo(other);

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act
                .ShouldThrow<AssertFailedException>()
                .WithMessage("Expected property Type to be*Int32*, but found*String*", ComparisonMode.Wildcard);
        }
开发者ID:uhaciogullari,项目名称:FluentAssertions.MonoTouch,代码行数:27,代码来源:EquivalencySpecs.cs

示例10: When_subject_has_a_property_not_available_in_expected_object_it_should_throw

        public void When_subject_has_a_property_not_available_in_expected_object_it_should_throw()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var subject = new
            {
                City = "Rijswijk"
            };

            var other = new
            {
            };

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.ShouldBeEquivalentTo(other);

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldThrow<AssertFailedException>().WithMessage(
                "Subject has property City that the other object does not have", ComparisonMode.StartWith);
        }
开发者ID:uhaciogullari,项目名称:FluentAssertions.MonoTouch,代码行数:25,代码来源:EquivalencySpecs.cs

示例11: When_comparing_anonymous_objects_by_their_shared_properties_and_one_property_does_not_match_it_should_throw

        public void When_comparing_anonymous_objects_by_their_shared_properties_and_one_property_does_not_match_it_should_throw()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var subject = new
            {
                Age = 36,
            };

            var other = new
            {
                Age = 37,
            };

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.ShouldBeEquivalentTo(other, options => options.ExcludingMissingProperties());

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldThrow<AssertFailedException>();
        }
开发者ID:uhaciogullari,项目名称:FluentAssertions.MonoTouch,代码行数:25,代码来源:EquivalencySpecs.cs

示例12: When_a_collection_property_contains_objects_with_matching_properties_it_should_not_throw

        public void When_a_collection_property_contains_objects_with_matching_properties_it_should_not_throw()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var expected = new
            {
                Customers = new[]
                {
                    new Customer
                    {
                        Age = 38,
                        Birthdate = 20.September(1973),
                        Name = "John"
                    },
                    new Customer
                    {
                        Age = 32,
                        Birthdate = 31.July(1978),
                        Name = "Jane"
                    }
                }
            };

            var subject = new
            {
                Customers = new[]
                {
                    new CustomerDto
                    {
                        Age = 38,
                        Birthdate = 20.September(1973),
                        Name = "John"
                    },
                    new CustomerDto
                    {
                        Age = 32,
                        Birthdate = 31.July(1978),
                        Name = "Jane"
                    }
                }
            };

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.ShouldBeEquivalentTo(expected);

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldNotThrow();
        }
开发者ID:uhaciogullari,项目名称:FluentAssertions.MonoTouch,代码行数:53,代码来源:EquivalencySpecs.cs

示例13: When_all_the_shared_properties_of_the_nested_objects_are_equal_it_should_succeed

        public void When_all_the_shared_properties_of_the_nested_objects_are_equal_it_should_succeed()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var subject = new
            {
                Level = new
                {
                    Text = "Level1",
                    Property = "Property"
                }
            };

            var expected = new
            {
                Level = new
                {
                    Text = "Level1",
                    OtherProperty = "OtherProperty"
                }
            };

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.ShouldBeEquivalentTo(expected, options => options.ExcludingMissingProperties());

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldNotThrow();
        }
开发者ID:uhaciogullari,项目名称:FluentAssertions.MonoTouch,代码行数:33,代码来源:EquivalencySpecs.cs

示例14: When_not_all_the_properties_of_the_nested_object_exist_on_the_expected_object_it_should_throw

        public void When_not_all_the_properties_of_the_nested_object_exist_on_the_expected_object_it_should_throw()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var subject = new
            {
                Level = new
                {
                    Text = "Level1",
                    OtherProperty = "OtherProperty"
                }
            };

            var expected = new
            {
                Level = new
                {
                    Text = "Level1"
                }
            };

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.ShouldBeEquivalentTo(expected);

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act
                .ShouldThrow<AssertFailedException>()
                .WithMessage("Subject has property Level.OtherProperty that the other object does not have", ComparisonMode.Substring);
        }
开发者ID:uhaciogullari,项目名称:FluentAssertions.MonoTouch,代码行数:34,代码来源:EquivalencySpecs.cs

示例15: Then_they_should_override_the_global_options

            public void Then_they_should_override_the_global_options()
            {
                var actual = new
                {
                    Value = (1D/3D)
                };

                var expected = new
                {
                    Value = 0.33D
                };

                Action act = () => actual.ShouldBeEquivalentTo(expected, options => options
                    .Using<double>(ctx => ctx.Subject.Should().Be(ctx.Expectation))
                    .WhenTypeIs<double>());

                act.ShouldThrow<AssertFailedException>().WithMessage("Expected*");
            }
开发者ID:leijiancd,项目名称:fluentassertions,代码行数:18,代码来源:AssertionOptionSpecs.cs


注:本文中的System.ShouldBeEquivalentTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。