public async Task FailIfStudyIsMissingName(string name) { await ClearTestDatabase(); var studyCreateService = StudyServiceMockFactory.CreateService(_serviceProvider); var studyWithInvalidName = new StudyCreateDto() { Name = name, Vendor = "Bouvet" }; await Assert.ThrowsAsync <ArgumentException>(() => studyCreateService.CreateAsync(studyWithInvalidName)); }
public async void FailIfStudyIsMissingVendor(string vendor) { await ClearTestDatabase(); var studyCreateService = StudyServiceMockFactory.CreateService(_serviceProvider); var studyWithInvalidVendor = new StudyCreateDto() { Name = "TestStudy", Vendor = vendor }; await Assert.ThrowsAsync <ArgumentException>(() => studyCreateService.CreateAsync(studyWithInvalidVendor)); }
public async void CloseStudyAsync_ShouldClose_IfStudyExists() { await ClearTestDatabase(); var studyDeleteService = StudyServiceMockFactory.DeleteService(_serviceProvider); var initialStudy = new StudyCreateDto() { Name = "TestStudy12345", Vendor = "Equinor" }; var studyCreateService = StudyServiceMockFactory.CreateService(_serviceProvider); var createdStudy = await studyCreateService.CreateAsync(initialStudy); await studyDeleteService.CloseStudyAsync(createdStudy.Id); var studyReadService = StudyServiceMockFactory.StudyEfModelService(_serviceProvider); _ = await Assert.ThrowsAsync <NotFoundException>(() => studyReadService.GetByIdAsync(createdStudy.Id, UserOperation.Study_Read)); }
public async void UpdatingStudyDetailsWithoutRequiredFieldsShouldBeWellHandled(string name, string vendor) { await ClearTestDatabase(); var studyCreateService = StudyServiceMockFactory.CreateService(_serviceProvider); var initialStudy = new StudyCreateDto() { Name = "TestStudy12345", Vendor = "Equinor" }; var createdStudy = await studyCreateService.CreateAsync(initialStudy); var studyWithoutReqFields = new StudyUpdateDto() { Name = name, Vendor = vendor }; var studyUpdateService = StudyServiceMockFactory.UpdateService(_serviceProvider); await Assert.ThrowsAsync <ArgumentException>(() => studyUpdateService.UpdateMetadataAsync(createdStudy.Id, studyWithoutReqFields)); }