public async Task EditTechnicalAdvisor_WhenEditingUserThatIsNotTechnicalAdvisor_SaveChangesShouldNotBeCalled() { ArrangeUsersWithOneAdministratorUser(); await _technicalAdvisorService.Edit(123, new EditTechnicalAdvisorRequestDto()); await _nyssContext.DidNotReceive().SaveChangesAsync(); }
public async Task EditGlobalCoordinator_WhenEditingUserThatIsNotGlobalCoordinator_SaveChangesShouldNotBeCalled() { ArrangeUsersDbSetWithOneAdministratorUser(); await _globalCoordinatorService.Edit(new EditGlobalCoordinatorRequestDto { Id = 123 }); await _nyssContext.DidNotReceive().SaveChangesAsync(); }
public async Task AddSmsGateway_WhenNationalSocietyDoesNotExist_ShouldReturnError() { // Arrange const int nonExistentNationalSocietyId = 0; var nationalSocieties = new[] { new NationalSociety { Id = 1, Name = "National Society" } }; var nationalSocietiesMockDbSet = nationalSocieties.AsQueryable().BuildMockDbSet(); _nyssContextMock.NationalSocieties.Returns(nationalSocietiesMockDbSet); var gatewaySettingRequestDto = new GatewaySettingRequestDto { Name = "New SMS Gateway", ApiKey = "new-api-key", GatewayType = GatewayType.SmsEagle }; // Act var result = await _smsGatewayService.Create(nonExistentNationalSocietyId, gatewaySettingRequestDto); // Assert await _nyssContextMock.GatewaySettings.DidNotReceive().AddAsync(Arg.Any <GatewaySetting>()); await _nyssContextMock.DidNotReceive().SaveChangesAsync(); var content = Arg.Any <string>(); await _smsGatewayBlobProviderMock.DidNotReceive().UpdateApiKeys(content); result.IsSuccess.ShouldBeFalse(); result.Message.Key.ShouldBe(ResultKey.NationalSociety.SmsGateway.NationalSocietyDoesNotExist); }
public async Task EditManager_WhenEditingUserThatIsNotManager_SaveChangesShouldNotBeCalled() { await _managerService.Edit(_administratorId, new EditManagerRequestDto()); await _nyssContext.DidNotReceive().SaveChangesAsync(); }