public void ReturnErrorsWhenWorngDate()
        {
            var exampleCSV = TestCSV.GetTestCSV_WrongDate();
            var parser     = new ProductsCSVParser();

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

            Assert.Null(result);
            Assert.True(parser.HasErrors);
            Assert.NotEmpty(parser.Errors);
        }
        public void ParseCSVFile()
        {
            var exampleCSV = TestCSV.GetTestCSV1();
            var parser     = new ProductsCSVParser();

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

            Assert.NotNull(result);

            Assert.Equal("0889059664247", result[0].EAN);
            Assert.Equal("NordsDropShip", result[0].Vendor);

            Assert.Equal("0889059664248", result[1].EAN);
            Assert.Equal("NordsDropShip", result[1].Vendor);
        }
Exemple #3
0
        public void InsertValidCSVFormattedProductListIn()
        {
            //Arrange
            string productcsv  = TestCSV.GetTestCSV1();
            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;
            ApiOkResponse <object> apiResponse = JsonConvert.DeserializeObject <ApiOkResponse <object> >(responseString);
            var content = JsonConvert.DeserializeObject <Content <object> >(apiResponse.Content.Result.ToString());

            Assert.Equal((int)StatusCodes.Status201Created, (int)response.StatusCode);
            Assert.Equal("Success", content.Result.ToString());
        }
Exemple #4
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);
        }