public UBLDocument Enrich(IssueCommandExtended issueCommand) { var issueContext = issueCommand.IssueContext; var document = issueCommand.Document(); if (issueContext.IsInContingencyMode && issueContext.IsTaxAgencyInContingency) { switch (document) { case Invoice invoice when issueContext.DocumentTypeCode.EsFacturaElectronica(): invoice.ChangeDocument_TypeCode(InvoiceTypeCode.TaxAgencyContingencyFA.ToCode()); issueCommand.InvoiceTypeCode = InvoiceTypeCode.TaxAgencyContingencyFA.ToCode(); break; case DocumentoEquivalenteEx documentoEquivalenteEx when issueContext.DocumentTypeCode.EsDocumentoEquivalenteSinNotas(): documentoEquivalenteEx.ChangeDocument_TypeCode(InvoiceTypeCode.TaxAgencyContingencyDQ.ToCode()); issueCommand.InvoiceTypeCode = InvoiceTypeCode.TaxAgencyContingencyDQ.ToCode(); break; case DocumentoEquivalenteBiep documentoEquivalenteBiep when issueContext.DocumentTypeCode.EsDocumentoEquivalenteSinNotas(): documentoEquivalenteBiep.ChangeDocument_TypeCode(InvoiceTypeCode.TaxAgencyContingencyDQ.ToCode()); issueCommand.InvoiceTypeCode = InvoiceTypeCode.TaxAgencyContingencyDQ.ToCode(); break; case DocumentoEquivalenteCp documentoEquivalenteCp when issueContext.DocumentTypeCode.EsDocumentoEquivalenteSinNotas(): documentoEquivalenteCp.ChangeDocument_TypeCode(InvoiceTypeCode.TaxAgencyContingencyDQ.ToCode()); issueCommand.InvoiceTypeCode = InvoiceTypeCode.TaxAgencyContingencyDQ.ToCode(); break; case DocumentoEquivalenteDettp documentoEquivalenteDettp when issueContext.DocumentTypeCode.EsDocumentoEquivalenteSinNotas(): documentoEquivalenteDettp.ChangeDocument_TypeCode(InvoiceTypeCode.TaxAgencyContingencyDQ.ToCode()); issueCommand.InvoiceTypeCode = InvoiceTypeCode.TaxAgencyContingencyDQ.ToCode(); break; case DocumentoEquivalenteJl documentoEquivalenteJl when issueContext.DocumentTypeCode.EsDocumentoEquivalenteSinNotas(): documentoEquivalenteJl.ChangeDocument_TypeCode(InvoiceTypeCode.TaxAgencyContingencyDQ.ToCode()); issueCommand.InvoiceTypeCode = InvoiceTypeCode.TaxAgencyContingencyDQ.ToCode(); break; case DocumentoEquivalenteLobv documentoEquivalenteLobv when issueContext.DocumentTypeCode.EsDocumentoEquivalenteSinNotas(): documentoEquivalenteLobv.ChangeDocument_TypeCode(InvoiceTypeCode.TaxAgencyContingencyDQ.ToCode()); issueCommand.InvoiceTypeCode = InvoiceTypeCode.TaxAgencyContingencyDQ.ToCode(); break; case DocumentoEquivalentePos documentoEquivalentePos when issueContext.DocumentTypeCode.EsDocumentoEquivalenteSinNotas(): documentoEquivalentePos.ChangeDocument_TypeCode(InvoiceTypeCode.TaxAgencyContingencyDQ.ToCode()); issueCommand.InvoiceTypeCode = InvoiceTypeCode.TaxAgencyContingencyDQ.ToCode(); break; case DocumentoEquivalenteSpd documentoEquivalenteSpd when issueContext.DocumentTypeCode.EsDocumentoEquivalenteSinNotas(): documentoEquivalenteSpd.ChangeDocument_TypeCode(InvoiceTypeCode.TaxAgencyContingencyDQ.ToCode()); issueCommand.InvoiceTypeCode = InvoiceTypeCode.TaxAgencyContingencyDQ.ToCode(); break; case DocumentoEquivalenteTbap documentoEquivalenteTbap when issueContext.DocumentTypeCode.EsDocumentoEquivalenteSinNotas(): documentoEquivalenteTbap.ChangeDocument_TypeCode(InvoiceTypeCode.TaxAgencyContingencyDQ.ToCode()); issueCommand.InvoiceTypeCode = InvoiceTypeCode.TaxAgencyContingencyDQ.ToCode(); break; } } return document; }
using Microsoft.VisualStudio.TestTools.UnitTesting; using System; namespace IssueCommandExtended_Enrich_Tests { [TestClass] public class UnitTest1 { [TestMethod] public void TestMethod1() { var issueContext = new IssueContext { DocumentTypeCode = "01" }; var issueCommand = new IssueCommandExtended { IssueContext = issueContext }; var document = issueCommand.Enrich(issueCommand); Assert.AreEqual(document.DocumentTypeCode, "01"); } [TestMethod] public void TestMethod2() { var issueContext = new IssueContext { DocumentTypeCode = "01", IsInContingencyMode = true }; var issueCommand = new IssueCommandExtended { IssueContext = issueContext }; var document = issueCommand.Enrich(issueCommand); Assert.AreEqual(document.DocumentTypeCode, "01"); } [TestMethod] public void TestMethod3()