PageRenderTime 38ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/MusicStore.UnitTest/GetProductsByCategoryTest.cs

https://github.com/satish860/MusicStoreAPI
C# | 49 lines | 46 code | 3 blank | 0 comment | 0 complexity | 201fe6ac2155e20cbe154d3667a7a01c MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using NUnit.Framework;
  7. using FluentAssertions;
  8. using MusicStore.Api.Query;
  9. using MusicStore.Api.Models;
  10. using MusicStore.Api;
  11. using System.Web.Http.SelfHost;
  12. namespace MusicStore.UnitTest
  13. {
  14. [TestFixture]
  15. public class GetProductsByCategoryTest
  16. {
  17. [TestFixtureSetUp]
  18. public void SetUp()
  19. {
  20. new MusicStoreBootStrap(new HttpSelfHostConfiguration("http://localhost:8008"))
  21. .ConfigureDatabaseForTest()
  22. .SeedDatabase();
  23. }
  24. [Test]
  25. public void Should_be_able_to_Get_the_products_By_Category()
  26. {
  27. IQueryFor<CategoryName, ListOfProducts> getallproductQuery = TestInstance.ProductsByCategoryQuery;
  28. ListOfProducts products=getallproductQuery.Execute(new CategoryName{Name="Mobile"});
  29. products.Products.Select(p => p.Id).Should().BeEquivalentTo(Enumerable.Range(1, 4));
  30. }
  31. [Test]
  32. public void Should_return_the_Count_of_the_Product()
  33. {
  34. IQueryFor<CategoryName, ListOfProducts> getallproductQuery = TestInstance.ProductsByCategoryQuery;
  35. ListOfProducts products = getallproductQuery.Execute(new CategoryName { Name = "Mobile" });
  36. products.PageCount.Should().Be(1);
  37. }
  38. [Test]
  39. public void Should_return_the_Zero_Result_When_there_is_no_Item_Found()
  40. {
  41. IQueryFor<CategoryName, ListOfProducts> getallproductQuery = TestInstance.ProductsByCategoryQuery;
  42. ListOfProducts products = getallproductQuery.Execute(new CategoryName { Name = "Mobile1" });
  43. products.PageCount.Should().Be(0);
  44. }
  45. }
  46. }