public void ShouldFailToBuildAClassWithAValidReferenceIfReferenceLoactionNotSupplied() { var unreferencedClass = Class.FromPath(GetClassPath("ReferencedDependency.cs.txt")); var buildFiles = new BuildFiles(unreferencedClass, new List <Class>(), new List <Reference>()); var compilationResult = new BuildFilesCompiler().Compile(buildFiles); Assert.That(compilationResult.HasErrors); }
public void ShouldBuildASingleEmptyClassWithoutError() { var emptyClass = Class.FromPath(GetClassPath("EmptyClass.cs.txt")); var buildFiles = new BuildFiles(emptyClass, new List <Class>(), new List <Reference>()); var compilationResult = new BuildFilesCompiler().Compile(buildFiles); Assert.That(!compilationResult.HasErrors); Assert.That(!string.IsNullOrEmpty(compilationResult.AssemblyLocation)); }
public void ShouldBuildAClassWithAValidReferenceIfReferenceLoactionIsSupplied() { var unreferencedClass = Class.FromPath(GetClassPath("ReferencedDependency.cs.txt")); var buildFiles = new BuildFiles(unreferencedClass, new List <Class>(), new List <Reference> { new Reference("ICSharpCode.NRefactory") }); var compilationResult = new BuildFilesCompiler().Compile(buildFiles); Assert.That(!compilationResult.HasErrors); }
private static void CopyBuildFilesToTempDir(BuildFiles buildFiles) { Console.WriteLine("\nFound classes:"); Console.WriteLine("-------------------------------"); foreach (var dependentClass in buildFiles.DependentClasses) { Console.WriteLine(" - " + dependentClass.ClassName); } Console.WriteLine("\nFound references:"); Console.WriteLine("-------------------------------"); CopyReferencesToTempDir(buildFiles.References.Where(r => r.IsExternalAssembily)); }
public void AddBuildFile(IFile file) { if (this.Equals(file)) { return; } else if (BuildSource.Equals(file)) { return; } else if (BuildFiles.Where(f => f.Equals(file)).Count() == 0) { _BuildFiles.Add(file); } }
public static bool HasAClassCalled(this BuildFiles buildFiles, string name) { return(buildFiles.DependentClasses.Any(c => c.ClassName == name)); }
public static bool HasAReferenceCalled(this BuildFiles buildFiles, string name) { return(buildFiles.References.Any(c => c.FullPath == name)); }
public async Task <ReceivedDigitalDocument> SendElectronicInvoiceToMH(FacturaElectronica payload, string accountId) { ReceivedDigitalDocument InvoiceResponse = new ReceivedDigitalDocument(); IRequestRecordLog requestRecordLog; BuildFiles buildFiles; HttpResponseMessage responseMessage; XmlDocument xmlDocInvoice; string pdfInvoice; object newRequest = null; try { buildFiles = new BuildFiles(); xmlDocInvoice = new XmlDocument(); requestRecordLog = new RequestRecordLog(); xmlDocInvoice = Utils.GetXmlFromObject(payload); #region Sign XML and Validate against XSD CustomSignature.SignXML(payload.FechaEmision, ref xmlDocInvoice, accountId); //IList<IError> listErros = DataValidator.Instance().ValidateXML(xmlDocInvoice.OuterXml, xsdDocument.FacturaElectronica); //if(listErros.Count > 0) //{ // throw new Exception(string.Format(Constants.Constants.RequestApiFormat_2, Constants.Constants.xml_has_errors, Utils.ConcatElements(listErros)) ); //} #endregion #region Crear PDF pdfInvoice = buildFiles.GetPDFInvoice(payload, accountId); #endregion #region Crea el request de Factura Digital para Hacienda if (payload.Receptor != null) { newRequest = new { clave = payload.Clave, fecha = payload.FechaEmision, emisor = new { tipoIdentificacion = payload.Emisor.Identificacion.Tipo, numeroIdentificacion = payload.Emisor.Identificacion.Numero }, comprobanteXml = Convert.ToBase64String(Encoding.UTF8.GetBytes(xmlDocInvoice.OuterXml)), callbackUrl = string.Format(Constants.Constants.RequestApiFormat_2, ConfigurationManager.AppSettings[Constants.Constants.serverDomain], ConfigurationManager.AppSettings[Constants.Constants.CallBackUrl]) }; } else { newRequest = new { clave = payload.Clave, fecha = payload.FechaEmision, emisor = new { tipoIdentificacion = payload.Emisor.Identificacion.Tipo, numeroIdentificacion = payload.Emisor.Identificacion.Numero }, receptor = new { tipoIdentificacion = payload.Receptor.Identificacion.Tipo, numeroIdentificacion = payload.Receptor.Identificacion.Tipo }, comprobanteXml = Convert.ToBase64String(Encoding.UTF8.GetBytes(xmlDocInvoice.OuterXml)), callbackUrl = string.Format(Constants.Constants.RequestApiFormat_2, ConfigurationManager.AppSettings[Constants.Constants.serverDomain], ConfigurationManager.AppSettings[Constants.Constants.CallBackUrl]) }; } #endregion try { HttpCustomClient client = new HttpCustomClient(); InvoiceResponse = await client.Post(newRequest, Constants.Constants.mhActionRecepcion, Constants.Constants.mhEndpoint, accountId); InvoiceResponse.xmlInvoice = Convert.ToBase64String(Encoding.UTF8.GetBytes(xmlDocInvoice.OuterXml)); InvoiceResponse.pdfInvoice = pdfInvoice; } catch (Exception ex) { throw ex; } } catch (CryptographicException e) { throw e; } return(InvoiceResponse); }