示例#1
0
        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);
                }
            }
        }
示例#2
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));
        }
示例#3
0
        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);
        }