public void AcquireToken_WhenGrantTypeIsNull_ThrowsIntranetValidationExceptionWhereValidatingTypeIsTypeOfString() { Controller sut = CreateSut(); IntranetValidationException result = Assert.Throws <IntranetValidationException>(() => sut.AcquireToken(null)); Assert.That(result.ValidatingType, Is.EqualTo(typeof(string))); }
public void AcquireToken_WhenGrantTypeIsNull_ThrowsIntranetValidationExceptionWhereValidatingFieldIsEqualToGrantType() { Controller sut = CreateSut(); IntranetValidationException result = Assert.Throws <IntranetValidationException>(() => sut.AcquireToken(null)); Assert.That(result.ValidatingField, Is.EqualTo("grantType")); }
public void AcquireToken_WhenGrantTypeIsEmpty_ThrowsIntranetValidationExceptionWhereErrorCodeIsEqualToValueCannotBeNullOrWhiteSpace() { Controller sut = CreateSut(); IntranetValidationException result = Assert.Throws <IntranetValidationException>(() => sut.AcquireToken(string.Empty)); Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ValueCannotBeNullOrWhiteSpace)); }
public void AcmeChallenge_WhenChallengeTokenIsNull_ThrowsIntranetValidationExceptionWhereValidatingFieldIsEqualToChallengeToken() { Controller sut = CreateSut(); IntranetValidationException result = Assert.Throws <IntranetValidationException>(() => sut.AcmeChallenge(null)); Assert.That(result.ValidatingField, Is.EqualTo("challengeToken")); }
public void AcmeChallenge_WhenChallengeTokenIsEmpty_ThrowsIntranetValidationExceptionWhereValidatingTypeIsTypeOfString() { Controller sut = CreateSut(); IntranetValidationException result = Assert.Throws <IntranetValidationException>(() => sut.AcmeChallenge(string.Empty)); Assert.That(result.ValidatingType, Is.EqualTo(typeof(string))); }
public void AcmeChallenge_WhenChallengeTokenIsNull_ThrowsIntranetValidationExceptionWhereErrorCodeIsEqualToValueCannotBeNullOrWhiteSpace() { Controller sut = CreateSut(); IntranetValidationException result = Assert.Throws <IntranetValidationException>(() => sut.AcmeChallenge(null)); Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ValueCannotBeNullOrWhiteSpace)); }
public void Build_WhenCalledForIntranetValidationExceptionWithoutValidatingField_AssertValidatingFieldIsNull() { IIntranetExceptionBuilder sut = CreateSut(ErrorCode.ValueNotGreaterThanZero, _fixture.Create <string>()); IntranetValidationException result = (IntranetValidationException)sut.Build(); Assert.That(result.ValidatingField, Is.Null); }
public void GenerateGenericKeyAsync_WhenKeyElementCollectionIsEmpty_ThrowsIntranetValidationException() { IKeyGenerator sut = CreateSut(); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.GenerateGenericKeyAsync(Array.Empty <string>())); Assert.That(result, Is.Not.Null); }
public void ApplyPostingJournalAsync_WhenApplyPostingJournalModelIsInvalid_ThrowsIntranetValidationExceptionWhereErrorCodeIsEqualToValueCannotBeNull() { Controller sut = CreateSut(modelIsValid: false); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.ApplyPostingJournalAsync(CreateApplyPostingJournalModel())); Assert.That(result, Is.Not.Null); Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.SubmittedMessageInvalid)); }
public void BudgetAccountAsync_WhenAccountNumberIsEmpty_ThrowsIntranetValidationExceptionWhereErrorCodeIsEqualToValueCannotBeNullOrWhiteSpace() { Controller sut = CreateSut(); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.BudgetAccountAsync(_fixture.Create <int>(), string.Empty)); Assert.That(result, Is.Not.Null); Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ValueCannotBeNullOrWhiteSpace)); }
public void BudgetAccountAsync_WhenAccountNumberIsNull_ThrowsIntranetValidationExceptionWhereValidatingFieldIsEqualToAccountNumber() { Controller sut = CreateSut(); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.BudgetAccountAsync(_fixture.Create <int>(), null)); Assert.That(result, Is.Not.Null); Assert.That(result.ValidatingField, Is.EqualTo("accountNumber")); }
public void BudgetAccountAsync_WhenAccountNumberIsNull_ThrowsIntranetValidationExceptionWhereValidatingTypeIsTypeOfString() { Controller sut = CreateSut(); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.BudgetAccountAsync(_fixture.Create <int>(), null)); Assert.That(result, Is.Not.Null); Assert.That(result.ValidatingType, Is.EqualTo(typeof(string))); }
public void ApplyPostingJournalAsync_WhenApplyPostingJournalModelIsNull_ThrowsIntranetValidationExceptionWhereValidatingFieldIsEqualToApplyPostingJournal() { Controller sut = CreateSut(); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.ApplyPostingJournalAsync(null)); Assert.That(result, Is.Not.Null); Assert.That(result.ValidatingField, Is.EqualTo("applyPostingJournal")); }
public void AccountAsync_WhenAccountWasNotReturnedFromQueryBus_ThrowsIntranetValidationExceptionWhereValidatingTypeIsTypeOfString() { Controller sut = CreateSut(false); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.AccountAsync(_fixture.Create <int>(), _fixture.Create <string>())); Assert.That(result, Is.Not.Null); Assert.That(result.ValidatingType, Is.EqualTo(typeof(string))); }
public void ApplyPostingJournalAsync_WhenApplyPostingLineCollectionModelIsNull_ThrowsIntranetValidationExceptionWhereValidatingTypeIsTypeOfApplyPostingLineCollectionModel() { Controller sut = CreateSut(); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.ApplyPostingJournalAsync(_fixture.Create <int>(), null)); Assert.That(result, Is.Not.Null); Assert.That(result.ValidatingType, Is.EqualTo(typeof(ApplyPostingLineCollectionModel))); }
public void ApplyPostingJournalAsync_WhenApplyPostingJournalModelIsNull_ThrowsIntranetValidationExceptionWhereErrorCodeIsEqualToValueCannotBeNull() { Controller sut = CreateSut(); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.ApplyPostingJournalAsync(null)); Assert.That(result, Is.Not.Null); Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ValueCannotBeNull)); }
public void BudgetAccountAsync_WhenBudgetAccountWasNotReturnedFromQueryBus_ThrowsIntranetValidationExceptionWhereErrorCodeIsEqualToValueShouldBeKnown() { Controller sut = CreateSut(false); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.BudgetAccountAsync(_fixture.Create <int>(), _fixture.Create <string>())); Assert.That(result, Is.Not.Null); Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ValueShouldBeKnown)); }
public void BudgetAccountAsync_WhenBudgetAccountWasNotReturnedFromQueryBus_ThrowsIntranetValidationExceptionWhereValidatingFieldIsEqualToAccountNumber() { Controller sut = CreateSut(false); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.BudgetAccountAsync(_fixture.Create <int>(), _fixture.Create <string>())); Assert.That(result, Is.Not.Null); Assert.That(result.ValidatingField, Is.EqualTo("accountNumber")); }
public void ApplyPostingJournalAsync_WhenApplyPostingJournalModelIsInvalid_ThrowsIntranetValidationExceptionWhereValidatingFieldIsNull() { Controller sut = CreateSut(modelIsValid: false); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.ApplyPostingJournalAsync(CreateApplyPostingJournalModel())); Assert.That(result, Is.Not.Null); Assert.That(result.ValidatingField, Is.Null); }
public void ApplyPostingJournalAsync_WhenApplyPostingLineCollectionModelIsInvalid_ThrowsIntranetValidationExceptionWhereValidatingTypeIsNull() { Controller sut = CreateSut(modelIsValid: false); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.ApplyPostingJournalAsync(_fixture.Create <int>(), CreateApplyPostingLineCollectionModel())); Assert.That(result, Is.Not.Null); Assert.That(result.ValidatingType, Is.Null); }
public void Build_WhenCalledForIntranetValidationExceptionWithValidatingField_AssertValidatingFieldIsCorrect() { IIntranetExceptionBuilder sut = CreateSut(ErrorCode.ValueNotGreaterThanZero, _fixture.Create <string>()); string validatingField = _fixture.Create <string>(); IntranetValidationException result = (IntranetValidationException)sut.WithValidatingField(validatingField).Build(); Assert.That(result.ValidatingField, Is.EqualTo(validatingField)); }
public void GenerateUserSpecificKeyAsync_WhenKeyElementCollectionIsEmpty_ThrowsIntranetValidationExceptionWhereInnerExceptionIsNull() { IKeyGenerator sut = CreateSut(); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.GenerateUserSpecificKeyAsync(Array.Empty <string>())); // ReSharper disable PossibleNullReferenceException Assert.That(result.InnerException, Is.Null); // ReSharper restore PossibleNullReferenceException }
public void GenerateGenericKeyAsync_WhenKeyElementCollectionIsEmpty_ThrowsIntranetValidationExceptionWhereMessageContainsKeyElementCollection() { IKeyGenerator sut = CreateSut(); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.GenerateGenericKeyAsync(Array.Empty <string>())); // ReSharper disable PossibleNullReferenceException Assert.That(result.Message.Contains("keyElementCollection"), Is.True); // ReSharper restore PossibleNullReferenceException }
public void GenerateGenericKeyAsync_WhenKeyElementCollectionIsEmpty_ThrowsIntranetValidationExceptionWhereValidatingTypeIsEqualToStringEnumerable() { IKeyGenerator sut = CreateSut(); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.GenerateGenericKeyAsync(Array.Empty <string>())); // ReSharper disable PossibleNullReferenceException Assert.That(result.ValidatingType, Is.EqualTo(typeof(IEnumerable <string>))); // ReSharper restore PossibleNullReferenceException }
public void GenerateGenericKeyAsync_WhenKeyElementCollectionIsEmpty_ThrowsIntranetValidationExceptionWhereErrorCodeIsEqualToValueShouldContainSomeItems() { IKeyGenerator sut = CreateSut(); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.GenerateGenericKeyAsync(Array.Empty <string>())); // ReSharper disable PossibleNullReferenceException Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ValueShouldContainSomeItems)); // ReSharper restore PossibleNullReferenceException }
public void ApplyPostingJournalAsync_WhenApplyPostingJournalModelIsInvalid_ThrowsIntranetValidationExceptionWhereMessageContainsErrorMessage() { string errorMessage = _fixture.Create <string>(); Controller sut = CreateSut(modelIsValid: false, errorMessage: errorMessage); IntranetValidationException result = Assert.ThrowsAsync <IntranetValidationException>(async() => await sut.ApplyPostingJournalAsync(CreateApplyPostingJournalModel())); Assert.That(result, Is.Not.Null); Assert.That(result.Message, Is.Not.Null); Assert.That(result.Message.Contains(errorMessage), Is.True); }
public void ShouldNotBeNull_WhenValueIsNull_ThrowsIntranetValidationException() { IStringValidator sut = CreateSut(); Type validatingType = GetType(); string validatingField = _fixture.Create <string>(); IntranetValidationException result = Assert.Throws <IntranetValidationException>(() => sut.ShouldNotBeNull(null, validatingType, validatingField)); Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ValueCannotBeNull)); Assert.That(result.ValidatingType, Is.EqualTo(validatingType)); Assert.That(result.ValidatingField, Is.EqualTo(validatingField)); }
public void ShouldBeDeletable_WhenValueIsNullAndNullIsNotAllowed_ThrowsIntranetValidationException() { IObjectValidator sut = CreateSut(); Type validatingType = GetType(); string validatingField = _fixture.Create <string>(); IntranetValidationException result = Assert.Throws <IntranetValidationException>(() => sut.ShouldBeDeletable <object, IDeletable>(null, async obj => await Task.Run(() => _fixture.BuildDeletableMock().Object), validatingType, validatingField)); Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ValueCannotBeNull)); Assert.That(result.ValidatingType, Is.EqualTo(validatingType)); Assert.That(result.ValidatingField, Is.EqualTo(validatingField)); }
public void ShouldBeGreaterThanOrEqualToZero_WhenValueIsLowerThanZero_ThrowsIntranetValidationException() { IIntegerValidator sut = CreateSut(); Type validatingType = GetType(); string validatingField = _fixture.Create <string>(); IntranetValidationException result = Assert.Throws <IntranetValidationException>(() => sut.ShouldBeGreaterThanOrEqualToZero(_random.Next(1, 5) * -1, validatingType, validatingField)); Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ValueNotGreaterThanOrEqualToZero)); Assert.That(result.ValidatingType, Is.EqualTo(validatingType)); Assert.That(result.ValidatingField, Is.EqualTo(validatingField)); }
public void ShouldBeFutureDate_WhenValueDateIsToday_ThrowsIntranetValidationException() { IDateTimeValidator sut = CreateSut(); DateTime value = DateTime.Today; Type validatingType = GetType(); string validatingField = _fixture.Create <string>(); IntranetValidationException result = Assert.Throws <IntranetValidationException>(() => sut.ShouldBeFutureDate(value, validatingType, validatingField)); Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ValueShouldBeFutureDate)); Assert.That(result.ValidatingType, Is.EqualTo(validatingType)); Assert.That(result.ValidatingField, Is.EqualTo(validatingField)); }