public async Task ShouldThrowValidationExceptionOnModifyIfStudentGuardianDoesntExistAndLogItAsync()
        {
            // given
            int             randomNegativeMinutes = GetNegativeRandomNumber();
            DateTimeOffset  dateTime = GetRandomDateTime();
            StudentGuardian randomStudentGuardian      = CreateRandomStudentGuardian(dateTime);
            StudentGuardian nonExistentStudentGuardian = randomStudentGuardian;

            nonExistentStudentGuardian.CreatedDate = dateTime.AddMinutes(randomNegativeMinutes);
            StudentGuardian noStudentGuardian = null;
            var             notFoundStudentGuardianException = new NotFoundStudentGuardianException
                                                                   (nonExistentStudentGuardian.StudentId, nonExistentStudentGuardian.GuardianId);

            var expectedStudentGuardianValidationException =
                new StudentGuardianValidationException(notFoundStudentGuardianException);

            this.storageBrokerMock.Setup(broker =>
                                         broker.SelectStudentGuardianByIdAsync(
                                             nonExistentStudentGuardian.StudentId, nonExistentStudentGuardian.GuardianId))
            .ReturnsAsync(noStudentGuardian);

            this.dateTimeBrokerMock.Setup(broker =>
                                          broker.GetCurrentDateTime())
            .Returns(dateTime);

            // when
            ValueTask <StudentGuardian> modifyStudentGuardianTask =
                this.studentGuardianService.ModifyStudentGuardianAsync(nonExistentStudentGuardian);

            // then
            await Assert.ThrowsAsync <StudentGuardianValidationException>(() =>
                                                                          modifyStudentGuardianTask.AsTask());

            this.dateTimeBrokerMock.Verify(broker =>
                                           broker.GetCurrentDateTime(),
                                           Times.Once);

            this.storageBrokerMock.Verify(broker =>
                                          broker.SelectStudentGuardianByIdAsync
                                              (nonExistentStudentGuardian.StudentId, nonExistentStudentGuardian.GuardianId),
                                          Times.Once);

            this.loggingBrokerMock.Verify(broker =>
                                          broker.LogError(It.Is(SameExceptionAs(
                                                                    expectedStudentGuardianValidationException))),
                                          Times.Once);

            this.loggingBrokerMock.VerifyNoOtherCalls();
            this.storageBrokerMock.VerifyNoOtherCalls();
            this.dateTimeBrokerMock.VerifyNoOtherCalls();
        }
        public async Task ShouldThrowValidationExceptionOnDeleteWhenStorageStudentGuardianIsInvalidAndLogItAsync()
        {
            // given
            DateTimeOffset  randomDateTime             = GetRandomDateTime();
            StudentGuardian randomStudentGuardian      = CreateRandomStudentGuardian(randomDateTime);
            Guid            inputStudentGuardianId     = randomStudentGuardian.GuardianId;
            Guid            inputStudentId             = randomStudentGuardian.StudentId;
            StudentGuardian nullStorageStudentGuardian = null;

            var notFoundStudentGuardianException =
                new NotFoundStudentGuardianException(inputStudentGuardianId, inputStudentId);

            var expectedStudentGuardianValidationException =
                new StudentGuardianValidationException(notFoundStudentGuardianException);

            this.storageBrokerMock.Setup(broker =>
                                         broker.SelectStudentGuardianByIdAsync(inputStudentGuardianId, inputStudentId))
            .ReturnsAsync(nullStorageStudentGuardian);
            // when
            ValueTask <StudentGuardian> actualStudentGuardianDeleteTask =
                this.studentGuardianService.RemoveStudentGuardianByIdsAsync(inputStudentGuardianId, inputStudentId);

            // then
            await Assert.ThrowsAsync <StudentGuardianValidationException>(() =>
                                                                          actualStudentGuardianDeleteTask.AsTask());

            this.loggingBrokerMock.Verify(broker =>
                                          broker.LogError(It.Is(SameExceptionAs(
                                                                    expectedStudentGuardianValidationException))),
                                          Times.Once);

            this.storageBrokerMock.Verify(broker =>
                                          broker.SelectStudentGuardianByIdAsync(inputStudentGuardianId, inputStudentId),
                                          Times.Once);

            this.storageBrokerMock.Verify(broker =>
                                          broker.DeleteStudentGuardianAsync(It.IsAny <StudentGuardian>()),
                                          Times.Never);

            this.storageBrokerMock.VerifyNoOtherCalls();
            this.loggingBrokerMock.VerifyNoOtherCalls();
            this.dateTimeBrokerMock.VerifyNoOtherCalls();
        }