static async Task Main() { Console.Clear(); var sourceFileUrl = GetSourceFileUrl(); var targetFilePath = GetTargetFilePath(); var downloadedStream = await Download(sourceFileUrl); var clothsService = new ClothsService(); try { var importedCloths = await clothsService.ImportFromCsv(downloadedStream); var exportSubjects = importedCloths.Where(cloth => cloth.Price.Amount >= 10); await clothsService.ExportClothesToCsvFile(targetFilePath, exportSubjects, Currency.Euro); } catch (LineImportException importException) { await Console.Error.WriteLineAsync(importException.Message); await Console.Error.WriteLineAsync(importException.InnerException?.ToString()); } catch (Exception unhandled) { await Console.Error.WriteLineAsync(unhandled.Message); } #if debug Console.WriteLine("All completed, press a key to close"); Console.ReadKey(); #endif }
public async Task WhenImportingCsvFileWithoutHeader_ThenImportedClothesAreReturned() { var memStream = WithValidClothsStream(false); var service = new ClothsService(); var cloths = await service.ImportFromCsv(memStream, false); Assert.AreEqual(cloths.Count, 3); }
public async Task WhenClothLinesAreExported_ThenAFileIsCreated() { var cloths = new List <Cloth>() { new Cloth(123, "Some name", "Some Description", new Price(5, Currency.Euro), "pants") }; var service = new ClothsService(); await service.ExportClothesToCsvFile(_filename, cloths, Currency.Dollar); Assert.IsTrue(File.Exists(_filename)); }