public void ReturnErrorsWhenWorngData()
        {
            var exampleCSV = TestCSV.GetTestCSV2_Wrong();
            var parser     = new ProductsCSVParser();

            parser.TryParse(exampleCSV);
            var result = parser.Result;

            Assert.Null(result);
            Assert.True(parser.HasErrors);
            Assert.NotEmpty(parser.Errors);
        }
Example #2
0
        public void ErrorOnInsertWithInvalidCSVFormattedProductListIn()
        {
            //Arrange
            string productcsv  = TestCSV.GetTestCSV2_Wrong();             //input contains two error lines
            var    postContent = new StringContent(productcsv, Encoding.UTF8, "text/plain");

            postContent.Headers.Remove("Content-Type");
            postContent.Headers.Add("Content-Type", "text/plain");

            HttpResponseMessage response = _client.PostAsync("api/v1/Product/", postContent).Result;

            var responseString = response.Content.ReadAsStringAsync().Result;
            ApiBadRequestResponse apiBadResponse = JsonConvert.DeserializeObject <ApiBadRequestResponse>(responseString);

            var result = apiBadResponse.Errors.ToList();


            Assert.Equal((int)StatusCodes.Status400BadRequest, (int)response.StatusCode);
            Assert.True(result.Count == 2);
            Assert.Equal("Check csv parser error list", apiBadResponse.Message);
        }