Ejemplo n.º 1
0
        public void If_nullable_value_is_not_allowed_then_assertion_should_throw_api_exception(string @operator)
        {
            var guid    = Guid.NewGuid();
            var filters = new List <FilterItem>();
            Expression <Func <GuidAssertionsTestEntity, Guid?> > expression = p => p.NullableNotAllowedMember;
            var subject = new NullableGuidAssertions(expression, filters);

            Action assertion = null;

            if (@operator != "=")
            {
                assertion = () => subject.BeNull();
            }
            if (@operator != "!=")
            {
                assertion = () => subject.NotBeNull();
            }

            assertion.Should().Throw <ApiException>();
        }
Ejemplo n.º 2
0
        public void Assertion_with_null_value_should_add_filter(string @operator)
        {
            var guid    = Guid.NewGuid();
            var filters = new List <FilterItem>();
            Expression <Func <GuidAssertionsTestEntity, Guid?> > expression = p => p.NullableMember;
            var subject = new NullableGuidAssertions(expression, filters);

            if (@operator == "=")
            {
                subject.BeNull();
            }
            else if (@operator == "!=")
            {
                subject.NotBeNull();
            }

            filters.Should().HaveCount(1);
            filters[0].Name.Should().Be("nullableMember");
            filters[0].Operator.Should().Be(@operator);
            filters[0].Value.Should().BeNull();
        }