public async Task ImportAsync_MustImportStatesFromCsvFile_True(string file) { // Arrange string filename = Helper.GetFilePath(file); IImportStateService stateService = Helper.GetImportStateService(); // // Act // var result = await stateService.ImportAsync(filename); // Assert Assert.True(result.Success); if (result.Success) { List <List <State> > states = (List <List <State> >)result.Data; Assert.NotNull(states); Assert.True(states.Count > 0); for (int i = 0, j = states.Count; i < j; i++) { Assert.True(states[i].Count > 0); } } }
public async Task <IActionResult> State([FromRoute] Guid token) { CommandResponse commandResponse; Stopwatch watch = Stopwatch.StartNew(); if (!ModelState.IsValid) { commandResponse = FormatResponse(ModelState); } else { CommandResult commandResult; if (token != _bigaiId) { commandResult = CommandResult.Unauthorized("Authorization token is not valid."); } else { commandResult = UploadCsv(); if (commandResult.Success) { commandResult = await _importStateService.ImportAsync(commandResult.Data.ToString()); } } commandResponse = FormatResponse(commandResult); } watch.Stop(); commandResponse.ElapsedTime = watch.ElapsedMilliseconds; return(StatusCode(commandResponse.StatusCode, commandResponse)); }
public async Task ImportAsync_MustImportStatesFromCsvFile_False(string file) { // Arrange string filename = Helper.GetFilePath(file); IImportStateService stateService = Helper.GetImportStateService(); // // Act // var result = await stateService.ImportAsync(filename); // Assert Assert.False(result.Success); }