public async Task CreateDataCollector_WhenSuccess_ShouldReturnSuccess(DataCollectorType type, string displayName) { // Arrange var dataCollector = new CreateDataCollectorRequestDto { DataCollectorType = type, PhoneNumber = "+4712344567", DisplayName = displayName, SupervisorId = SupervisorId, VillageId = _nyssContextMock.Villages.ToList()[0].Id, Latitude = 15, Longitude = 45 }; // Act await _dataCollectorService.Create(ProjectId, dataCollector); // Assert await _nyssContextMock.Received(1).AddAsync(Arg.Any <DataCollector>()); }
public async Task EditDataCollector_WhenSuccessful_ShouldReturnSuccess(DataCollectorType type, string displayName) { // Arrange var dataCollector = new EditDataCollectorRequestDto { DataCollectorType = type, Id = DataCollectorWithoutReportsId, DisplayName = displayName, PhoneNumber = DataCollectorPhoneNumber1, SupervisorId = SupervisorId, VillageId = _nyssContextMock.Villages.ToList()[0].Id, Latitude = 15, Longitude = 45 }; // Act var result = await _dataCollectorService.Edit(dataCollector); // Assert result.IsSuccess.ShouldBeTrue(); result.Message.Key.ShouldBe(ResultKey.DataCollector.EditSuccess); }
public void ValidateReport_WhenReportIsNotCorrect_ShouldThrowException(ReportType reportType, DataCollectorType dataCollectorType, HealthRiskType healthRiskType) { // Arrange var projectId = 1; var healthRiskCode = 1; var projectHealthRisks = new List <ProjectHealthRisk> { new ProjectHealthRisk { Project = new Project { Id = projectId }, HealthRisk = new HealthRisk { HealthRiskType = healthRiskType, HealthRiskCode = healthRiskCode } } }; var projectHealthRisksDbSet = projectHealthRisks.AsQueryable().BuildMockDbSet(); _nyssContextMock.ProjectHealthRisks.Returns(projectHealthRisksDbSet); var parsedReport = new ParsedReport { ReportType = reportType, HealthRiskCode = healthRiskCode }; var dataCollector = new DataCollector { DataCollectorType = dataCollectorType, Project = new Project { Id = projectId } }; // Assert Should.Throw <ReportValidationException>(async() => await _smsEagleHandler.ValidateReport(parsedReport, dataCollector)); }