public void Execute_ReturnsImmediatelyAsModulusWeightsAlreadyLoaded() { // Arrange _modulusWeightRepository.Count().Returns(10); // Act _sut.Execute(); // Assert _fileSystemAccess.DidNotReceiveWithAnyArgs().ReadAllLines(default(string)); }
public void Execute() { if (_modulusWeightRepository.Count() > 0) { return; } var fullDataFilePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Resources\valacdos.txt"); _logger.LogDebug($"Attempting to read file '{fullDataFilePath}'..."); var fileContent = _fileSystemAccess.ReadAllLines(fullDataFilePath); _logger.LogDebug($"File read successfully ({fileContent.Length} lines). Attempting to transform and load data..."); foreach (var line in fileContent) { _modulusWeightRepository.Insert(_modulusWeightEntityMapper.Create(line)); } _logger.LogDebug("All lines processed. Attempting to save the entities to the database..."); _modulusWeightRepository.SaveChanges(); }