public async Task <string> ProcessInspectionResultsAsync(Guid inspectionId, CancellationToken cancellationToken) { var generator = new PreShiftSummaryGenerator(); var testData = await GetTestDataAsync(inspectionId); if (testData == null) { return(null); } var summary = generator.GenerateSummary(_environmentId, inspectionId, testData.Employee, testData.SvmrRawData, testData.HrvRawData); summary.DepartmentId = testData.Inspection.DepartmentId; summary.BranchOfficeId = testData.Inspection.BranchOfficeId; // add shift start date & number summary.WorkingShiftDate = RusHydroScheduler.GetShiftStartDate( summary.CompletionTime.LocalDateTime, out bool isDayShift, out int shiftNumber); summary.WorkingShiftNumber = shiftNumber; await StoreSummary(summary); return($"api/plugins/rushydro-psa/summary/inspection/{inspectionId}"); }
private void Expect( IDictionary <TestInfo, JObject> testData, PsaStatus expectedSvmrStatus, PsaStatus expectedHrvStatus, PsaStatus expectedFinalStatus, string expectedPathSuffix, string expectedFileNamePrefix, string expectedFileNameSuffix ) { //var interceptor = new SummaryInterceptor(new SummaryRendererRtf()); //var writer = new SummaryWriterInterceptor(new SummaryWriter()); //var renderers = new ISummaryRenderer[] { interceptor }; var generator = new PreShiftSummaryGenerator(); var pskOnlineTestData = testData; var employee = new Employee { FullName = "John Doe", BranchOfficeName = "Ферма №212", DepartmentName = "Разделочный цех", PositionName = "Обвальщик" }; // When // Rushydro rules are applied for generating summary var summary = generator.GenerateSummary( "someDatabaseId", Guid.NewGuid(), employee, pskOnlineTestData); // Then // final status and individual method statuses // meet the specification in the method's parameters Assert.AreEqual(expectedSvmrStatus, summary.SvmrConclusion.Status, "SVMR status"); Assert.AreEqual(expectedHrvStatus, summary.HrvConclusion.Status, "HRV status"); Assert.AreEqual(expectedFinalStatus, summary.FinalConclusion.Status, "OVERALL status"); //Assert.IsTrue(writer._writeCalled, "Write must have been called"); //_log.InfoFormat("Summary written to the file: '{0}'", writer._usedSummaryFileName); //string actualSummaryFileName = Path.GetDirectoryName(writer._usedSummaryFileName); //Assert.IsTrue(actualSummaryFileName.EndsWith(expectedPathSuffix), // $"Expected summary directory suffix is '{expectedPathSuffix}'; not found within '{actualSummaryFileName}'"); //Assert.IsTrue(Path.GetFileName(writer._usedSummaryFileName).StartsWith(expectedFileNamePrefix), // "Expected summary file name prefix must be " + expectedFileNamePrefix // ); //Assert.IsTrue(Path.GetFileName(writer._usedSummaryFileName).EndsWith(expectedFileNameSuffix), // "Expected summary file name suffix must be " + expectedPathSuffix // ); //_log.Info(summary); Assert.IsNotEmpty(summary.Employee.FullName, "Summary shall contain non-empty employee name"); Assert.Greater(summary.CompletionTime, DateTimeOffset.MinValue, "Summary shall contain a meaningful completion date"); Assert.Less(summary.CompletionTime, DateTimeOffset.MaxValue, "Summary shall contain a meaningful completion date"); // Assert.IsNotEmpty(summary.Employee.DepartmentName, "Summary shall contain non-empty department name for the employee"); Assert.IsNotEmpty(summary.Employee.PositionName, "Summary shall contain non-empty position name for the employee"); }