コード例 #1
0
        public void PropertyByPropertNameSHouldThrowExceptionIfNameIsWrongTest()
        {
            // When
            Action act = () => Selectors.Property <string, int>("qwe");

            // Then
            act.Should()
            .Throw <InvalidOperationException>()
            .WithMessage("Property \"qwe\" is not found in type \"System.String\".");
        }
コード例 #2
0
        public void PropertyTest()
        {
            // When
            var result = Selectors.Property <string, int>("Length");

            // Then
            using (new AssertionScope())
            {
                result.Should().Equal(x => x.Length);
                result.Call("123").Should().Be(3);
            }
        }
コード例 #3
0
        public void PropertyByPropertyInfoTest()
        {
            // Given
            var propertyInfo = typeof(string).GetRuntimeProperty("Length");

            // When
            var result = Selectors.Property <string, int>(propertyInfo);

            // Then
            using (new AssertionScope())
            {
                result.Should().Equal(x => x.Length);
                result.Call("123").Should().Be(3);
            }
        }