public async Task ShouldDeleteStudentExamFeeAsync() { // given StudentExamFee randomStudentExamFee = await PostRandomStudentExamFeeAsync(); StudentExamFee inputStudentExamFee = randomStudentExamFee; StudentExamFee expectedStudentExamFee = inputStudentExamFee; Guid inputStudentId = randomStudentExamFee.StudentId; Guid inputExamFeeId = randomStudentExamFee.ExamFeeId; // when StudentExamFee deletedStudentExamFee = await DeleteStudentExamFeeAsync(inputStudentExamFee); ValueTask <StudentExamFee> getStudentExamFeeByIdTask = this.otripleSApiBroker.GetStudentExamFeeByIdsAsync( inputStudentId, inputExamFeeId); // then deletedStudentExamFee.Should().BeEquivalentTo(expectedStudentExamFee); await Assert.ThrowsAsync <HttpResponseNotFoundException>(() => getStudentExamFeeByIdTask.AsTask()); }
public async Task ShouldGetAllStudentExamFeesAsync() { // given int randomNumber = GetRandomNumber(); var randomStudentExamFees = new List <StudentExamFee>(); for (int i = 0; i < randomNumber; i++) { randomStudentExamFees.Add(await PostRandomStudentExamFeeAsync()); } List <StudentExamFee> inputStudentExamFees = randomStudentExamFees; List <StudentExamFee> expectedStudentExamFees = inputStudentExamFees.ToList(); // when List <StudentExamFee> actualStudentExamFees = await this.otripleSApiBroker.GetAllStudentExamFeesAsync(); // then foreach (StudentExamFee expectedStudentExamFee in expectedStudentExamFees) { StudentExamFee actualStudentExamFee = actualStudentExamFees.Single( studentExamFee => studentExamFee.StudentId == expectedStudentExamFee.StudentId && studentExamFee.ExamFeeId == expectedStudentExamFee.ExamFeeId); actualStudentExamFee.Should().BeEquivalentTo(expectedStudentExamFee); await DeleteStudentExamFeeAsync(actualStudentExamFee); } }
public async Task ShouldRemoveStudentExamFeeAsync() { // given var randomStudentId = Guid.NewGuid(); var randomExamFeeId = Guid.NewGuid(); Guid inputStudentId = randomStudentId; Guid inputExamFeeId = randomExamFeeId; StudentExamFee randomStudentExamFee = CreateRandomStudentExamFee(); randomStudentExamFee.StudentId = inputStudentId; randomStudentExamFee.ExamFeeId = inputExamFeeId; StudentExamFee storageStudentExamFee = randomStudentExamFee; StudentExamFee expectedStudentExamFee = storageStudentExamFee; this.storageBrokerMock.Setup(broker => broker.SelectStudentExamFeeByIdsAsync( inputStudentId, inputExamFeeId)) .ReturnsAsync(storageStudentExamFee); this.storageBrokerMock.Setup(broker => broker.DeleteStudentExamFeeAsync(storageStudentExamFee)) .ReturnsAsync(expectedStudentExamFee); // when StudentExamFee actualStudentExamFee = await this.studentExamFeeService.RemoveStudentExamFeeByIdAsync( inputStudentId, inputExamFeeId); // then actualStudentExamFee.Should().BeEquivalentTo(expectedStudentExamFee); this.storageBrokerMock.Verify(broker => broker.SelectStudentExamFeeByIdsAsync( inputStudentId, inputExamFeeId), Times.Once); this.storageBrokerMock.Verify(broker => broker.DeleteStudentExamFeeAsync(storageStudentExamFee), Times.Once); this.storageBrokerMock.VerifyNoOtherCalls(); this.loggingBrokerMock.VerifyNoOtherCalls(); this.dateTimeBrokerMock.VerifyNoOtherCalls(); }
public async Task ShouldRetrieveStudentExamFeeByIdAsync() { // given Guid randomStudentId = Guid.NewGuid(); Guid inputStudentId = randomStudentId; Guid randomExamFeeId = Guid.NewGuid(); Guid inputExamFeeId = randomExamFeeId; DateTimeOffset randomDateTime = GetRandomDateTime(); StudentExamFee randomStudentExamFee = CreateRandomStudentExamFee(randomDateTime); StudentExamFee storageStudentExamFee = randomStudentExamFee; StudentExamFee expectedStudentExamFee = storageStudentExamFee; this.storageBrokerMock.Setup(broker => broker.SelectStudentExamFeeByIdsAsync( inputStudentId, inputExamFeeId)) .ReturnsAsync(storageStudentExamFee); // when StudentExamFee actualStudentExamFee = await this.studentExamFeeService.RetrieveStudentExamFeeByIdsAsync( inputStudentId, inputExamFeeId); // then actualStudentExamFee.Should().BeEquivalentTo(expectedStudentExamFee); this.dateTimeBrokerMock.Verify(broker => broker.GetCurrentDateTime(), Times.Never); this.storageBrokerMock.Verify(broker => broker.SelectStudentExamFeeByIdsAsync( inputStudentId, inputExamFeeId), Times.Once); this.dateTimeBrokerMock.VerifyNoOtherCalls(); this.storageBrokerMock.VerifyNoOtherCalls(); this.storageBrokerMock.VerifyNoOtherCalls(); }
public async Task ShouldPutStudentExamFeeAsync() { // given StudentExamFee randomStudentExamFee = await PostRandomStudentExamFeeAsync(); StudentExamFee modifiedStudentExamFee = await UpdateStudentExamFeeRandom(randomStudentExamFee); Guid inputStudentId = randomStudentExamFee.StudentId; Guid inputExamFeeId = randomStudentExamFee.ExamFeeId; // when await this.otripleSApiBroker.PutStudentExamFeeAsync(modifiedStudentExamFee); StudentExamFee actualStudentExamFee = await this.otripleSApiBroker.GetStudentExamFeeByIdsAsync( inputStudentId, inputExamFeeId); // then actualStudentExamFee.Should().BeEquivalentTo(modifiedStudentExamFee); await DeleteStudentExamFeeAsync(actualStudentExamFee); }
public async Task ShouldPostStudentExamFeeAsync() { // given StudentExamFee randomStudentExamFee = await CreateRandomStudentExamFeeAsync(); StudentExamFee inputStudentExamFee = randomStudentExamFee; StudentExamFee expectedStudentExamFee = inputStudentExamFee; Guid inputStudentId = inputStudentExamFee.StudentId; Guid inputExamFeeId = inputStudentExamFee.ExamFeeId; // when await this.otripleSApiBroker.PostStudentExamFeeAsync(inputStudentExamFee); StudentExamFee actualStudentExamFee = await this.otripleSApiBroker.GetStudentExamFeeByIdsAsync( inputStudentId, inputExamFeeId); // then actualStudentExamFee.Should().BeEquivalentTo(expectedStudentExamFee); await DeleteStudentExamFeeAsync(actualStudentExamFee); }
public async Task ShouldAddStudentExamFeeAsync() { // given DateTimeOffset dateTime = DateTimeOffset.UtcNow; StudentExamFee randomStudentExamFee = CreateRandomStudentExamFee(); randomStudentExamFee.UpdatedBy = randomStudentExamFee.CreatedBy; randomStudentExamFee.UpdatedDate = randomStudentExamFee.CreatedDate; StudentExamFee inputStudentExamFee = randomStudentExamFee; StudentExamFee storageStudentExamFee = randomStudentExamFee; StudentExamFee expectedStudentExamFee = randomStudentExamFee; this.dateTimeBrokerMock.Setup(broker => broker.GetCurrentDateTime()) .Returns(dateTime); this.storageBrokerMock.Setup(broker => broker.InsertStudentExamFeeAsync(inputStudentExamFee)) .ReturnsAsync(storageStudentExamFee); // when StudentExamFee actualStudentExamFee = await this.studentExamFeeService.AddStudentExamFeeAsync(inputStudentExamFee); // then actualStudentExamFee.Should().BeEquivalentTo(expectedStudentExamFee); this.dateTimeBrokerMock.Verify(broker => broker.GetCurrentDateTime(), Times.Once); this.storageBrokerMock.Verify(broker => broker.InsertStudentExamFeeAsync(inputStudentExamFee), Times.Once); this.storageBrokerMock.VerifyNoOtherCalls(); this.loggingBrokerMock.VerifyNoOtherCalls(); this.dateTimeBrokerMock.VerifyNoOtherCalls(); }
public async Task ShouldModifyStudentExamFeeAsync() { // given int randomNumber = GetRandomNumber(); int randomDays = randomNumber; DateTimeOffset randomDate = GetRandomDateTime(); DateTimeOffset randomInputDate = GetRandomDateTime(); StudentExamFee randomStudentExamFee = CreateRandomStudentExamFee(randomInputDate); StudentExamFee inputStudentExamFee = randomStudentExamFee; StudentExamFee afterUpdateStorageStudentExamFee = randomStudentExamFee; StudentExamFee expectedStudentExamFee = randomStudentExamFee; StudentExamFee beforeUpdateStorageStudentExamFee = randomStudentExamFee.DeepClone(); inputStudentExamFee.UpdatedDate = randomDate; Guid studentId = inputStudentExamFee.StudentId; Guid guardianId = inputStudentExamFee.ExamFeeId; this.dateTimeBrokerMock.Setup(broker => broker.GetCurrentDateTime()) .Returns(randomDate); this.storageBrokerMock.Setup(broker => broker.SelectStudentExamFeeByIdsAsync( inputStudentExamFee.StudentId, inputStudentExamFee.ExamFeeId)) .ReturnsAsync(beforeUpdateStorageStudentExamFee); this.storageBrokerMock.Setup(broker => broker.UpdateStudentExamFeeAsync(inputStudentExamFee)) .ReturnsAsync(afterUpdateStorageStudentExamFee); // when StudentExamFee actualStudentExamFee = await this.studentExamFeeService.ModifyStudentExamFeeAsync( inputStudentExamFee); // then actualStudentExamFee.Should().BeEquivalentTo(expectedStudentExamFee); this.dateTimeBrokerMock.Verify(broker => broker.GetCurrentDateTime(), Times.Once); this.storageBrokerMock.Verify(broker => broker.SelectStudentExamFeeByIdsAsync( inputStudentExamFee.StudentId, inputStudentExamFee.ExamFeeId), Times.Once); this.storageBrokerMock.Verify(broker => broker.UpdateStudentExamFeeAsync(inputStudentExamFee), Times.Once); this.dateTimeBrokerMock.VerifyNoOtherCalls(); this.storageBrokerMock.VerifyNoOtherCalls(); this.loggingBrokerMock.VerifyNoOtherCalls(); }