//Constructor /// <summary> /// Creates initialized instance based on given xml file. /// This is the only way to instantiate demo settings. /// </summary> /// <param name="fileName">Xml file consisting of demo cases definitions</param> public DemoSettings(string fileName) { //Validate xml file and load the document DocValidator validator = new DocValidator(); Assembly demoAssembly = Assembly.GetExecutingAssembly(); Assembly assemblyRCNet = Assembly.Load("RCNet"); using (Stream schemaStream = demoAssembly.GetManifestResourceStream("RCNet.DemoConsoleApp.DemoSettings.xsd")) { validator.AddSchema(schemaStream); } using (Stream schemaStream = assemblyRCNet.GetManifestResourceStream("RCNet.RCNetTypes.xsd")) { validator.AddSchema(schemaStream); } XDocument xmlDoc = validator.LoadXDocFromFile(fileName); //Parsing //Data folder XElement root = xmlDoc.Descendants("demo").First(); DataFolder = root.Attribute("dataFolder").Value; //Demo cases definitions CaseCfgCollection = new List <CaseSettings>(); foreach (XElement demoCaseParamsElem in root.Descendants("case")) { CaseCfgCollection.Add(new CaseSettings(demoCaseParamsElem, DataFolder)); } return; }
public DocValidatorTest() { doc = new Doc { Id = "1", Valor = 200, Meio = MeioTranferencia.Internet, Destinatario = new Destinatario { Agencia = "0085", Banco = "341", Conta = "421512", CPF = "73682426051", Nome = "Monike" }, Remetente = new Remetente { Agencia = "0652", Banco = "237", Conta = "0065232", CPF = "12873385006", Nome = "Rodrigo" } }; validations = new DocValidator(); }