Ejemplo n.º 1
0
        public void Fixture_Thing2()
        {
            var getter = new PropertyGetter();


            var fixture = new Fixture_Thing2()
            {
                Thing1 = new Fixture_Thing()
                {
                    A = "123",
                    B = 1,
                    C = null
                },
                D = 123,
                E = 1234L
            };

            var value = getter.Get(fixture, "Thing1.A");

            value.Should().Be("123");

            value = getter.Get(fixture, "Thing1.B");
            value.Should().Be(1);

            value = getter.Get(fixture, "Thing1.C");
            value.Should().BeNull();

            value = getter.Get(fixture, "D");
            value.Should().Be(123);

            value = getter.Get(fixture, "E");
            value.Should().Be(1234L);
        }
Ejemplo n.º 2
0
        public void Should_Fail_If_StringComparsion_IsSetWrong()
        {
            var getter = new PropertyGetter(comparison: StringComparison.Ordinal);


            var fixture = new Fixture_Thing2()
            {
                Thing1 = new Fixture_Thing()
                {
                    A = "123",
                    B = 1,
                    C = null
                },
                D = 123,
                E = 1234L
            };

            getter.TryGetPropertyDelegate(fixture, "thing1.a", out _).Should().BeFalse();
            getter.TryGetPropertyDelegate(fixture, "Thing1.A", out _).Should().BeTrue();
        }
Ejemplo n.º 3
0
        public void Should_Have_StronglyTypedExpression()
        {
            var getter = new PropertyGetter(comparison: StringComparison.OrdinalIgnoreCase);


            var fixture = new Fixture_Thing2()
            {
                Thing1 = new Fixture_Thing()
                {
                    A = "123",
                    B = 1,
                    C = null
                },
                D = 123,
                E = 1234L
            };


            getter.TryGetPropertyDelegate(fixture, "thing1.a", out var propertyDelegate);
            propertyDelegate.Should().NotBeNull();
            propertyDelegate.StronglyTypedExpression.Type.Should().Be <Func <Fixture_Thing2, string> >();
        }