public async Task ShouldThrowValidationExceptionOnModifyWhenCalendarEntryIsNullAndLogItAsync() { //given CalendarEntry invalidCalendarEntry = null; var nullCalendarEntryException = new NullCalendarEntryException(); var expectedCalendarEntryValidationException = new CalendarEntryValidationException(nullCalendarEntryException); //when ValueTask <CalendarEntry> modifyCalendarEntryTask = this.calendarEntryService.ModifyCalendarEntryAsync(invalidCalendarEntry); //then await Assert.ThrowsAsync <CalendarEntryValidationException>(() => modifyCalendarEntryTask.AsTask()); this.loggingBrokerMock.Verify(broker => broker.LogError(It.Is(SameExceptionAs( expectedCalendarEntryValidationException))), Times.Once); this.loggingBrokerMock.VerifyNoOtherCalls(); this.storageBrokerMock.VerifyNoOtherCalls(); this.dateTimeBrokerMock.VerifyNoOtherCalls(); }
public async void ShouldThrowValidationExceptionOnAddWhenCalendarEntryIsNullAndLogItAsync() { // given CalendarEntry randomCalendarEntry = null; CalendarEntry nullCalendarEntry = randomCalendarEntry; var nullCalendarEntryException = new NullCalendarEntryException(); var expectedCalendarEntryValidationException = new CalendarEntryValidationException(nullCalendarEntryException); // when ValueTask <CalendarEntry> registerCalendarEntryTask = this.calendarEntryService.AddCalendarEntryAsync(nullCalendarEntry); // then await Assert.ThrowsAsync <CalendarEntryValidationException>(() => registerCalendarEntryTask.AsTask()); this.loggingBrokerMock.Verify(broker => broker.LogError(It.Is(SameExceptionAs(expectedCalendarEntryValidationException))), Times.Once); this.storageBrokerMock.Verify(broker => broker.InsertCalendarEntryAsync(It.IsAny <CalendarEntry>()), Times.Never); this.dateTimeBrokerMock.VerifyNoOtherCalls(); this.loggingBrokerMock.VerifyNoOtherCalls(); this.storageBrokerMock.VerifyNoOtherCalls(); }