static void ExecuteApp() { IFileWriteService fileWriteServices = new FileWriteService(); IHendler <ImportFileCommand> importFileHendler = new ImportFileHendler(fileWriteServices); IFileReadService fileReadService = new FileReadService(); do { Count++; Console.Clear(); Console.WriteLine($"Processamento iniciado: {Count}"); Console.WriteLine(new ImportFileApp(importFileHendler, fileReadService, Configuration).ImportFile()); Console.WriteLine("Processamento finalizado."); Console.WriteLine("Deseja encerrar o Aplicativo? (s/n): "); string readLine; bool sucess = LineReader.TryReadLine(out readLine, int.Parse(Configuration["TimingToExecute"])); if (sucess) { if (readLine.ToLower().Equals("s")) { Exit = true; } } } while (!Exit); Process.GetCurrentProcess().Kill(); }
public void ExecuteAppTest() { IFileWriteService fileWriteServices = new FileWriteService(); IHendler <ImportFileCommand> importFileHendler = new ImportFileHendler(fileWriteServices); IFileReadService fileReadService = new FileReadService(); string retorno = new ImportFileApp(importFileHendler, fileReadService, Configuration).ImportFile(); }
public static string GetAdTemplateFileContent() { int days = Helper.GetCacheExpireDays(); string fileName = Helper.GetAdFileName(); IMemoryCache _memoryCache = Helper.GetDefaultMemoryCacheObject(); string content = new FileReadService(_memoryCache).FileAsString(fileName, days); return(content); }
public void Test_FileAsStream() { var anonymousData = new { Name = "Riya", Occupation = "Kavin Brother." }; string content = new FileReadService(Helper.GetDefaultMemoryCacheObject()).FillContent(Helper.GetAdTemplateFileContent(), anonymousData); Stream stream = new FileReadService(Helper.GetDefaultMemoryCacheObject()).FileAsStream(content); Action act = () => stream.Should().NotBeNull(); act.Should().NotThrow(); }
public void Test_FileAsString() { int days = Helper.GetCacheExpireDays(); string fileName = Helper.GetAdFileName(); IMemoryCache _memoryCache = Helper.GetDefaultMemoryCacheObject(); string firstTimeContent = new FileReadService(_memoryCache).FileAsString(fileName, days); Action act = () => firstTimeContent.Should().NotBeEmpty(); act.Should().NotThrow(); string secondTimeContent = new FileReadService(_memoryCache).FileAsString(fileName, days); act = () => secondTimeContent.Should().BeSameAs(firstTimeContent); act.Should().NotThrow(); }
public void Test_FillContent() { var anonymousData = new { Name = "Riya", Occupation = "Kavin Brother." }; string content = new FileReadService(Helper.GetDefaultMemoryCacheObject()).FillContent(Helper.GetAdTemplateFileContent(), anonymousData); Action act = () => content.Should().Contain(anonymousData.Name); act.Should().NotThrow(); Action act1 = () => content.Should().Contain(anonymousData.Occupation); act1.Should().NotThrow(); }
public void Read_Xslt_File() { //init var xsltStr = "Xslt string"; //Setup var mockRepository = new Mock <IFileReadRepository>(); mockRepository.Setup(m => m.ReadXsltFile()).Returns(xsltStr); var fileReadService = new FileReadService(mockRepository.Object); //act var returnedXML = fileReadService.ReadXsltFile(); //assert Assert.AreEqual(xsltStr, "Xslt string"); }
public void Read_Xslt_File() { //init var xsltStr = "Xslt string"; var xsltPath = @"C:\AirTicket\AirTicket\Resources\Computer.xslt"; //Setup var mockRepository = new Mock <IFileReadRepository>(); mockRepository.Setup(m => m.ReadXsltFile(xsltPath)).Returns(Task.FromResult(xsltStr)); var fileReadService = new FileReadService(mockRepository.Object, _airTicketsSettings); //act var returnedXML = fileReadService.ReadXsltFile(); //assert Assert.Equal("Xslt string", xsltStr); }
public void Read_Xml_Files() { //init var xmlList = new List <string>() { "Xml Data 1", "Xml Data 2", "Xml Data 3" }; //Setup var mockRepository = new Mock <IFileReadRepository>(); mockRepository.Setup(m => m.ReadXmlFile()).Returns(xmlList); var fileReadService = new FileReadService(mockRepository.Object); //act var returnedXML = fileReadService.ReadXmlFile(); //assert Assert.AreEqual(returnedXML.Count(), 3); }
public void Read_Xml_Files() { //init var xmlList = new List <string>() { "Xml Data 1", "Xml Data 2", "Xml Data 3" }; //Setup var mockRepository = new Mock <IFileReadRepository>(); mockRepository.Setup(m => m.ReadXmlFile(_airTicketsSettings.InputXmlPath)).Returns(Task.FromResult(xmlList)); var fileReadService = new FileReadService(mockRepository.Object, _airTicketsSettings); //act var returnedXML = fileReadService.ReadXmlFile(); //assert Assert.Equal(3, returnedXML.Result.Count()); }
public void LoadWithUncorrectFileNameTest(string fileName) { var fileReadService = new FileReadService(); Assert.Throws <FileNotFoundException>(() => fileReadService.ReadAllBytes(fileName)); }