public void GetLocationFinder() { string outputFile = OutputFile(); ILocationFinder locationFinder = _locationFinderFactory.GetLocationFinder(_inputFile, outputFile, _locationsFile); Assert.Equal(locationFinder, _locationFinderFactory.GetLocationFinder(_inputFile, outputFile, _locationsFile)); }
public void AddFileMapServices() { IServiceCollection services = new ServiceCollection(); services.AddFileMapServices(); IServiceProvider serviceProvider = services.BuildServiceProvider(); string outputFile = OutputFile(); ILocationFinder finder1, finder2; using (IServiceScope scope = serviceProvider.CreateScope()) { ILocationFinderFactory singletonFactory = scope.ServiceProvider.GetRequiredService <ILocationFinderFactory>(); finder1 = singletonFactory.GetLocationFinder(_inputFile, outputFile, _locationsFile); } using (IServiceScope scope = serviceProvider.CreateScope()) { ILocationFinderFactory singletonFactory = scope.ServiceProvider.GetRequiredService <ILocationFinderFactory>(); finder2 = singletonFactory.GetLocationFinder(_inputFile, outputFile, _locationsFile); } Assert.Equal(finder1, finder2); }
private static async Task MapLocations(string inputFile, string outputFile, string locationsFile) { Stopwatch watch = Stopwatch.StartNew(); ILocationFinder locationFinder = _locationFinderFactory.GetLocationFinder(inputFile, outputFile, locationsFile); Console.WriteLine($"Mapping from {inputFile} to {outputFile} using {locationsFile}"); await locationFinder.MapLocations().ContinueWith((task) => { watch.Stop(); ConsoleColor originalColor = Console.ForegroundColor; if (task.IsCompletedSuccessfully) { Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine($"Mapping successfully completed"); } else { Console.WriteLine($"Mapping completed with errors:"); Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine(task.Exception.Message); } Console.ForegroundColor = originalColor; Console.WriteLine($"{watch.ElapsedMilliseconds}ms elapsed"); }); }
public async Task MapLocations() { string outputFile = OutputFile(); ILocationFinder finder = _locationFinderFactory.GetLocationFinder(_inputFile, outputFile, _locationsFile); await finder.MapLocations(); using (StreamReader expectedFileStreamReader = new StreamReader(_expectedOutputFile)) using (StreamReader outputFileStreamReader = new StreamReader(outputFile)) { string expectedLine; while ((expectedLine = expectedFileStreamReader.ReadLine()) != null) { Assert.Equal(expectedLine, outputFileStreamReader.ReadLine()); } Assert.Null(outputFileStreamReader.ReadLine()); } }