public void UpdateNotFoundProductReview() { Initialize(); var productController = new SpxController() { Request = new HttpRequestMessage { Method = HttpMethod.Put, RequestUri = new Uri(ServiceBaseURL + "api/SPX/121") } }; productController.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration()); var reviewUpdate = new ReviewModel() { ReviewId = "2", User = "******", Rating = "5", Comments = "Good one!", }; const int reviewId = 121; _response = productController.Put(reviewId, reviewUpdate); Assert.AreEqual(_response.StatusCode, HttpStatusCode.NotModified); Assert.AreNotEqual(_response.StatusCode, HttpStatusCode.NotFound); }
public void GetReviewsByTitle() { Initialize(); var productController = new SpxController() { Request = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri(ServiceBaseURL + "api/SPX/Get/products/Til/reviews") } }; productController.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration()); _response = productController.GetReviews("titel"); Assert.AreEqual(_response.StatusCode, HttpStatusCode.OK); }
public void InsertInValidProductsBrandTest() { Initialize(); var productController = new SpxController() { Request = new HttpRequestMessage { Method = HttpMethod.Post, RequestUri = new Uri(ServiceBaseURL + "api/SPX/InsertProducts") } }; productController.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration()); var product = new List <Product>() { new Product() { Brand = "LGN", Title = "New Title", ShortDescription = "Good Product", DatePublished = DateTime.Now, Reviews = new List <Review>() { new Review() { User = "******", Rating = "4", Comments = "Nice one!", }, new Review() { User = "******", Rating = "4", Comments = "Nice one!", } } } }; _response = productController.InsertProducts(product); Assert.AreEqual(_response.StatusCode, HttpStatusCode.BadRequest); }
public void GetAllProductsTest() { Initialize(); var controller = new SpxController(); controller.Request = new HttpRequestMessage() { Method = HttpMethod.Get, RequestUri = new Uri(ServiceBaseURL + "api/SPX") }; controller.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration()); _response = controller.Get(); var responseResult = JsonConvert.DeserializeObject <List <Product> >(_response.Content.ReadAsStringAsync().Result); Assert.AreEqual(_response.StatusCode, HttpStatusCode.OK); Assert.AreEqual(responseResult.Any(), true); }