public async Task ShouldRetrieveExamFeeByIdAsync() { // given Guid randomExamFeeId = Guid.NewGuid(); Guid inputExamFeeId = randomExamFeeId; DateTimeOffset randomDateTime = GetRandomDateTime(); ExamFee randomExamFee = CreateRandomExamFee(randomDateTime); ExamFee storageExamFee = randomExamFee; ExamFee expectedExamFee = storageExamFee; this.storageBrokerMock.Setup(broker => broker.SelectExamFeeByIdAsync(inputExamFeeId)) .ReturnsAsync(storageExamFee); // when ExamFee actualExamFee = await this.examFeeService.RetrieveExamFeeByIdAsync(inputExamFeeId); // then actualExamFee.Should().BeEquivalentTo(expectedExamFee); this.dateTimeBrokerMock.Verify(broker => broker.GetCurrentDateTime(), Times.Never); this.storageBrokerMock.Verify(broker => broker.SelectExamFeeByIdAsync(inputExamFeeId), Times.Once); this.dateTimeBrokerMock.VerifyNoOtherCalls(); this.storageBrokerMock.VerifyNoOtherCalls(); this.storageBrokerMock.VerifyNoOtherCalls(); }
public async Task ShouldGetAllExamFeesAsync() { // given int randomNumber = GetRandomNumber(); var randomExamFees = new List <ExamFee>(); for (int i = 0; i < randomNumber; i++) { randomExamFees.Add(await PostRandomExamFeeAsync()); } List <ExamFee> inputExamFees = randomExamFees; List <ExamFee> expectedExamFees = inputExamFees.ToList(); // when List <ExamFee> actualExamFees = await this.otripleSApiBroker.GetAllExamFeesAsync(); // then foreach (ExamFee expectedExamFee in expectedExamFees) { ExamFee actualExamFee = actualExamFees.Single(student => student.Id == expectedExamFee.Id); actualExamFee.Should().BeEquivalentTo(expectedExamFee); await DeleteExamFeeAsync(actualExamFee); } }
public async Task ShouldModifyExamFeeAsync() { // given int randomNumber = GetRandomNumber(); int randomDays = randomNumber; DateTimeOffset randomDate = GetRandomDateTime(); DateTimeOffset randomInputDate = GetRandomDateTime(); ExamFee randomExamFee = CreateRandomExamFee(randomInputDate); ExamFee inputExamFee = randomExamFee; ExamFee afterUpdateStorageExamFee = inputExamFee; ExamFee expectedExamFee = afterUpdateStorageExamFee; ExamFee beforeUpdateStorageExamFee = randomExamFee.DeepClone(); inputExamFee.UpdatedDate = randomDate; Guid examExamFeeId = inputExamFee.Id; this.dateTimeBrokerMock.Setup(broker => broker.GetCurrentDateTime()) .Returns(randomDate); this.storageBrokerMock.Setup(broker => broker.SelectExamFeeByIdAsync(examExamFeeId)) .ReturnsAsync(beforeUpdateStorageExamFee); this.storageBrokerMock.Setup(broker => broker.UpdateExamFeeAsync(inputExamFee)) .ReturnsAsync(afterUpdateStorageExamFee); // when ExamFee actualExamFee = await this.examFeeService.ModifyExamFeeAsync(inputExamFee); // then actualExamFee.Should().BeEquivalentTo(expectedExamFee); this.dateTimeBrokerMock.Verify(broker => broker.GetCurrentDateTime(), Times.Once); this.storageBrokerMock.Verify(broker => broker.SelectExamFeeByIdAsync(examExamFeeId), Times.Once); this.storageBrokerMock.Verify(broker => broker.UpdateExamFeeAsync(inputExamFee), Times.Once); this.dateTimeBrokerMock.VerifyNoOtherCalls(); this.storageBrokerMock.VerifyNoOtherCalls(); this.loggingBrokerMock.VerifyNoOtherCalls(); }
public async Task ShouldPutExamFeeAsync() { // given ExamFee randomExamFee = await PostRandomExamFeeAsync(); ExamFee modifiedExamFee = await UpdateExamFeeRandom(randomExamFee); // when await this.otripleSApiBroker.PutExamFeeAsync(modifiedExamFee); ExamFee actualExamFee = await this.otripleSApiBroker.GetExamFeeByIdAsync(randomExamFee.Id); // then actualExamFee.Should().BeEquivalentTo(modifiedExamFee); await DeleteExamFeeAsync(actualExamFee); }
public async Task ShouldPostExamFeeAsync() { // given ExamFee randomExamFee = await CreateRandomExamFeeAsync(); ExamFee inputExamFee = randomExamFee; ExamFee expectedExamFee = inputExamFee; // when await this.otripleSApiBroker.PostExamFeeAsync(inputExamFee); ExamFee actualExamFee = await this.otripleSApiBroker.GetExamFeeByIdAsync(inputExamFee.Id); // then actualExamFee.Should().BeEquivalentTo(expectedExamFee); await DeleteExamFeeAsync(actualExamFee); }
public async Task ShouldDeleteExamFeeAsync() { // given ExamFee randomExamFee = await PostRandomExamFeeAsync(); ExamFee inputExamFee = randomExamFee; ExamFee expectedExamFee = inputExamFee; // when ExamFee deletedExamFee = await DeleteExamFeeAsync(inputExamFee); ValueTask <ExamFee> getExamFeeByIdTask = this.otripleSApiBroker.GetExamFeeByIdAsync(inputExamFee.Id); // then deletedExamFee.Should().BeEquivalentTo(expectedExamFee); await Assert.ThrowsAsync <HttpResponseNotFoundException>(() => getExamFeeByIdTask.AsTask()); }
public async Task ShouldAddExamFeeAsync() { // given DateTimeOffset dateTime = DateTimeOffset.UtcNow; ExamFee randomExamFee = CreateRandomExamFee(); randomExamFee.UpdatedBy = randomExamFee.CreatedBy; randomExamFee.UpdatedDate = randomExamFee.CreatedDate; ExamFee inputExamFee = randomExamFee; ExamFee storageExamFee = randomExamFee; ExamFee expectedExamFee = randomExamFee; this.dateTimeBrokerMock.Setup(broker => broker.GetCurrentDateTime()) .Returns(dateTime); this.storageBrokerMock.Setup(broker => broker.InsertExamFeeAsync(inputExamFee)) .ReturnsAsync(storageExamFee); // when ExamFee actualExamFee = await this.examFeeService.AddExamFeeAsync(inputExamFee); // then actualExamFee.Should().BeEquivalentTo(expectedExamFee); this.dateTimeBrokerMock.Verify(broker => broker.GetCurrentDateTime(), Times.Once); this.storageBrokerMock.Verify(broker => broker.InsertExamFeeAsync(inputExamFee), Times.Once); this.storageBrokerMock.VerifyNoOtherCalls(); this.loggingBrokerMock.VerifyNoOtherCalls(); this.dateTimeBrokerMock.VerifyNoOtherCalls(); }
public async Task ShouldDeleteExamFeeAsync() { // given DateTimeOffset dateTime = GetRandomDateTime(); ExamFee randomExamFee = CreateRandomExamFee(dateTime); Guid inputExamFeeId = randomExamFee.Id; ExamFee inputExamFee = randomExamFee; ExamFee storageExamFee = inputExamFee; ExamFee expectedExamFee = storageExamFee; this.storageBrokerMock.Setup(broker => broker.SelectExamFeeByIdAsync(inputExamFeeId)) .ReturnsAsync(inputExamFee); this.storageBrokerMock.Setup(broker => broker.DeleteExamFeeAsync(inputExamFee)) .ReturnsAsync(storageExamFee); // when ExamFee actualExamFee = await this.examFeeService.RemoveExamFeeByIdAsync(inputExamFeeId); //then actualExamFee.Should().BeEquivalentTo(expectedExamFee); this.storageBrokerMock.Verify(broker => broker.SelectExamFeeByIdAsync(inputExamFeeId), Times.Once); this.storageBrokerMock.Verify(broker => broker.DeleteExamFeeAsync(inputExamFee), Times.Once); this.storageBrokerMock.VerifyNoOtherCalls(); this.loggingBrokerMock.VerifyNoOtherCalls(); this.dateTimeBrokerMock.VerifyNoOtherCalls(); }