public void Can_serialize_then_parse_inspection_with_pdf_report() { TestDataHelper.InspectionShouldBeSuchAsConstructed(inspection_); inspection_.SetPdfReport(new PdfReport(new InspectionPdf(InspectionPdfModel.FromDomain(inspection_, farm_, checklist_, "JU", "") , "the_user").CreatePdf())); var factory = new InspectionFactory(); string json = factory.Serialize(inspection_); var inspection = factory.Parse(json); TestDataHelper.InspectionShouldBeSuchAsConstructed(inspection); inspection.PdfReport.Should().Be(inspection_.PdfReport); }
public void Can_generate_pdf_nok_with_compliance_due_and_auto_na_nc() { var inspection = TestDataHelper.ConstructInspection(); var farm = TestDataHelper.ConstructFarm(); var checklist = TestDataHelper.ConstructChecklist(); checklist.SetOutcome("R1,P1", InspectionOutcome.Ok); checklist.Find("R1,P2") .SetOutcome(InspectionOutcome.NotOk) .SetInspectorComment("Livret des sorties pas à jour => à remplir sous délai.") .SetDefect(new Defect("Livret des sorties pas à jour", Defect.Measurement.Unspecified), DefectSeriousness.Small); checklist.SetOutcome("R1", InspectionOutcome.NotOk); checklist.SetOutcome("R2,G1,P1", InspectionOutcome.Ok); checklist.SetOutcome("R2,G1,P2", InspectionOutcome.Ok); checklist.SetOutcome("R2,G1,P3", InspectionOutcome.Ok); checklist.SetOutcome("R2,G1", InspectionOutcome.Ok); checklist.Find("R2,G2,SG1,P3").SetOutcome(InspectionOutcome.NotInspected).SetAuto(); checklist.Find("R2,G2,SG1,P4").SetOutcome(InspectionOutcome.NotInspected).SetAuto(); checklist.Find("R2,G2").SetOutcome(InspectionOutcome.NotApplicable).SetAuto(); checklist.SetOutcome("R2", InspectionOutcome.Ok); inspection.RequireActionOfDocuments("Livret des sorties à jour", new DateTime(2021, 01, 29)); inspection.InspectorSigns(TestDataHelper.ConstructSignature("Joe l'inspecteur")); inspection.FarmerSigns(TestDataHelper.ConstructSignature(farm.FarmName)); inspection.Finish(new FinishStatus(new DateTime(2021, 01, 22), "Joe the inspector")); string cantonCode = "JU"; string userName = "******"; string logoPath = AppDomain.CurrentDomain.BaseDirectory + "\\img\\focaa.png"; var model = InspectionPdfModel.FromDomain(inspection, farm, checklist, cantonCode, logoPath); var pdf = new InspectionPdf(model, userName); File.WriteAllBytes(Path.GetTempFileName() + ".pdf", pdf.CreatePdf()); }