Exemplo n.º 1
0
        public void ShouldContainItems_WhenValueIsNullAndNullIsAllowed_ReturnsEnumerableValidator()
        {
            IEnumerableValidator sut = CreateSut();

            IValidator result = sut.ShouldContainItems <object>(null, GetType(), _fixture.Create <string>(), true);

            Assert.That(result, Is.TypeOf <BusinessLogic.Validation.EnumerableValidator>());
        }
Exemplo n.º 2
0
        public void ShouldContainItems_WhenValueIsNullAndNullIsAllowed_ReturnsNotNull()
        {
            IEnumerableValidator sut = CreateSut();

            IValidator result = sut.ShouldContainItems <object>(null, GetType(), _fixture.Create <string>(), true);

            Assert.That(result, Is.Not.Null);
        }
Exemplo n.º 3
0
        public void ShouldContainItems_WhenValueIsNotNullAndValueContainsItems_ReturnsEnumerableValidator()
        {
            IEnumerableValidator sut = CreateSut();

            IValidator result = sut.ShouldContainItems(_fixture.CreateMany <object>(_random.Next(5, 10)).ToArray(), GetType(), _fixture.Create <string>());

            Assert.That(result, Is.TypeOf <BusinessLogic.Validation.EnumerableValidator>());
        }
Exemplo n.º 4
0
        public void ShouldContainItems_WhenValidatingFieldIsWhiteSpace_ThrowsArgumentNullException()
        {
            IEnumerableValidator sut = CreateSut();

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.ShouldContainItems(_fixture.CreateMany <object>(_random.Next(5, 10)).ToArray(), GetType(), " "));

            // ReSharper disable PossibleNullReferenceException
            Assert.That(result.ParamName, Is.EqualTo("validatingField"));
            // ReSharper restore PossibleNullReferenceException
        }
Exemplo n.º 5
0
        public void ShouldContainItems_WhenValueIsNotNullAndValueDoesNotContainItems_ThrowsIntranetValidationException()
        {
            IEnumerableValidator sut = CreateSut();

            Type   validatingType              = GetType();
            string validatingField             = _fixture.Create <string>();
            IntranetValidationException result = Assert.Throws <IntranetValidationException>(() => sut.ShouldContainItems(Array.Empty <object>(), validatingType, validatingField));

            // ReSharper disable PossibleNullReferenceException
            Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ValueShouldContainSomeItems));
            Assert.That(result.ValidatingType, Is.EqualTo(validatingType));
            Assert.That(result.ValidatingField, Is.EqualTo(validatingField));
            Assert.That(result.InnerException, Is.Null);
            // ReSharper restore PossibleNullReferenceException
        }
Exemplo n.º 6
0
        public void ShouldContainItems_WhenValueIsNullAndNullIsNotAllowed_ThrowsIntranetValidationException()
        {
            IEnumerableValidator sut = CreateSut();

            Type   validatingType              = GetType();
            string validatingField             = _fixture.Create <string>();
            IntranetValidationException result = Assert.Throws <IntranetValidationException>(() => sut.ShouldContainItems <object>(null, validatingType, validatingField));

            // ReSharper disable PossibleNullReferenceException
            Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ValueCannotBeNull));
            Assert.That(result.ValidatingType, Is.EqualTo(validatingType));
            Assert.That(result.ValidatingField, Is.EqualTo(validatingField));
            // ReSharper restore PossibleNullReferenceException
        }