public async Task ShouldAddStudentRegistrationAsync() { // given StudentRegistration randomStudentRegistration = CreateRandomStudentRegistration(); StudentRegistration inputStudentRegistration = randomStudentRegistration; StudentRegistration storageStudentRegistration = randomStudentRegistration; StudentRegistration expectedStudentRegistration = storageStudentRegistration; this.storageBrokerMock.Setup(broker => broker.InsertStudentRegistrationAsync(inputStudentRegistration)) .ReturnsAsync(storageStudentRegistration); // when StudentRegistration actualStudentRegistration = await this.studentRegistrationService.AddStudentRegistrationAsync(inputStudentRegistration); // then actualStudentRegistration.Should().BeEquivalentTo(expectedStudentRegistration); this.storageBrokerMock.Verify(broker => broker.InsertStudentRegistrationAsync(inputStudentRegistration), Times.Once); this.storageBrokerMock.VerifyNoOtherCalls(); this.loggingBrokerMock.VerifyNoOtherCalls(); }
public async Task ShouldRetrieveStudentRegistrationByIdAsync() { // given Guid randomStudentId = Guid.NewGuid(); Guid inputStudentId = randomStudentId; Guid randomRegistrationId = Guid.NewGuid(); Guid inputRegistrationId = randomRegistrationId; StudentRegistration randomStudentRegistration = CreateRandomStudentRegistration(); StudentRegistration storageStudentRegistration = randomStudentRegistration; StudentRegistration expectedStudentRegistration = storageStudentRegistration; this.storageBrokerMock.Setup(broker => broker.SelectStudentRegistrationByIdAsync(inputStudentId, inputRegistrationId)) .ReturnsAsync(storageStudentRegistration); // when StudentRegistration actualStudentExam = await this.studentRegistrationService.RetrieveStudentRegistrationByIdAsync( inputStudentId, inputRegistrationId); // then actualStudentExam.Should().BeEquivalentTo(expectedStudentRegistration); this.storageBrokerMock.Verify(broker => broker.SelectStudentRegistrationByIdAsync(inputStudentId, inputRegistrationId), Times.Once); this.storageBrokerMock.VerifyNoOtherCalls(); this.loggingBrokerMock.VerifyNoOtherCalls(); }
public async Task ShouldGetAllStudentRegistrationsAsync() { // given var randomStudentRegistrations = new List <StudentRegistration>(); for (var i = 0; i <= GetRandomNumber(); i++) { StudentRegistration randomStudentRegistration = await PostStudentRegistrationAsync(); randomStudentRegistrations.Add(randomStudentRegistration); } List <StudentRegistration> inputStudentRegistrations = randomStudentRegistrations; List <StudentRegistration> expectedStudentRegistrations = inputStudentRegistrations; // when List <StudentRegistration> actualStudentRegistrations = await this.otripleSApiBroker.GetAllStudentRegistrationsAsync(); // then foreach (StudentRegistration expectedStudentRegistration in expectedStudentRegistrations) { StudentRegistration actualStudentRegistration = actualStudentRegistrations.Single(studentRegistration => studentRegistration.StudentId == expectedStudentRegistration.StudentId); actualStudentRegistration.Should().BeEquivalentTo(expectedStudentRegistration); await DeleteStudentRegistrationAsync(actualStudentRegistration); } }
public async Task ShouldRemoveStudentRegistrationByIdsAsync() { // given var randomStudentId = Guid.NewGuid(); var randomRegistrationId = Guid.NewGuid(); Guid inputStudentId = randomStudentId; Guid inputRegistrationId = randomRegistrationId; DateTimeOffset inputDateTime = GetRandomDateTime(); StudentRegistration randomStudentRegistration = CreateRandomStudentRegistration(inputDateTime); randomStudentRegistration.StudentId = inputStudentId; randomStudentRegistration.RegistrationId = inputRegistrationId; StudentRegistration storageStudentRegistration = randomStudentRegistration; StudentRegistration expectedStudentRegistration = storageStudentRegistration; this.storageBrokerMock.Setup(broker => broker.SelectStudentRegistrationByIdAsync(inputStudentId, inputRegistrationId)) .ReturnsAsync(storageStudentRegistration); this.storageBrokerMock.Setup(broker => broker.DeleteStudentRegistrationAsync(storageStudentRegistration)) .ReturnsAsync(expectedStudentRegistration); // when StudentRegistration actualStudentRegistration = await this.studentRegistrationService.RemoveStudentRegistrationByIdsAsync(inputStudentId, inputRegistrationId); // then actualStudentRegistration.Should().BeEquivalentTo(expectedStudentRegistration); this.storageBrokerMock.Verify(broker => broker.SelectStudentRegistrationByIdAsync(inputStudentId, inputRegistrationId), Times.Once); this.storageBrokerMock.Verify(broker => broker.DeleteStudentRegistrationAsync(storageStudentRegistration), Times.Once); this.storageBrokerMock.VerifyNoOtherCalls(); this.dateTimeBrokerMock.VerifyNoOtherCalls(); this.loggingBrokerMock.VerifyNoOtherCalls(); }
public async Task ShouldPostStudentRegistrationAsync() { // given StudentRegistration randomStudentRegistration = await CreateRandomStudentRegistration(); StudentRegistration inputStudentRegistration = randomStudentRegistration; StudentRegistration expectedStudentRegistration = inputStudentRegistration; // when await this.otripleSApiBroker.PostStudentRegistrationAsync(inputStudentRegistration); StudentRegistration actualStudentRegistration = await this.otripleSApiBroker.GetStudentRegistrationByIdsAsync( inputStudentRegistration.StudentId, inputStudentRegistration.RegistrationId); // then actualStudentRegistration.Should().BeEquivalentTo(expectedStudentRegistration); await DeleteStudentRegistrationAsync(actualStudentRegistration); }
public async Task ShouldDeleteStudentRegistrationAsync() { // given StudentRegistration randomStudentRegistration = await PostStudentRegistrationAsync(); StudentRegistration inputStudentRegistration = randomStudentRegistration; StudentRegistration expectedStudentRegistration = inputStudentRegistration; // when StudentRegistration deletedStudentRegistration = await DeleteStudentRegistrationAsync(inputStudentRegistration); ValueTask <StudentRegistration> getStudentRegistrationByIdTask = this.otripleSApiBroker.GetStudentRegistrationByIdsAsync( inputStudentRegistration.StudentId, inputStudentRegistration.RegistrationId); // then deletedStudentRegistration.Should().BeEquivalentTo(expectedStudentRegistration); await Assert.ThrowsAsync <HttpResponseNotFoundException>(() => getStudentRegistrationByIdTask.AsTask()); }