PageRenderTime 50ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/MusicStore.AcceptanceTest/1.4ProductSpec.cs

https://github.com/satish860/MusicStoreAPI
C# | 41 lines | 36 code | 5 blank | 0 comment | 0 complexity | 7f17a743e3fd7a897d4cbdcd01121399 MD5 | raw file
  1. using FluentAssertions;
  2. using MusicStore.Api.Models;
  3. using Newtonsoft.Json.Linq;
  4. using NSpec;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Net.Http;
  9. namespace MusicStore.AcceptanceTest
  10. {
  11. public class ProductsSpec : nspec
  12. {
  13. public void Given_the_List_of_Products_added_to_the_Database()
  14. {
  15. it["Should be able to get upto first 10 products without sending page number"] = () =>
  16. {
  17. var client = HttpClientFactory.CreateClient();
  18. HttpResponseMessage message = client.GetAsync("/api/products/GetAll/1").Result;
  19. JObject items = JObject.Parse(message.Content.ReadAsStringAsync().Result);
  20. ListOfProducts productViewModels = items.ToObject<ListOfProducts>();
  21. productViewModels.Products.Select(p => p.Id).Should().ContainInOrder(Enumerable.Range(1, 10));
  22. };
  23. it["Should be able to get 10 products based on the page Number"] = () =>
  24. {
  25. var client = HttpClientFactory.CreateClient();
  26. HttpResponseMessage message = client.GetAsync("/api/products/GetAll/2").Result;
  27. JObject items = JObject.Parse(message.Content.ReadAsStringAsync().Result);
  28. ListOfProducts productViewModels = items.ToObject<ListOfProducts>();
  29. productViewModels.Products.Select(p => p.Id).Should().ContainInOrder(Enumerable.Range(11, 7));
  30. };
  31. xit["Should be able to get the details about the product by selecting the product"] = () =>
  32. {
  33. };
  34. }
  35. }
  36. }