PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/MusicStore.UnitTest/AddProductCommandUnitTest.cs

https://github.com/satish860/MusicStoreAPI
C# | 29 lines | 28 code | 1 blank | 0 comment | 0 complexity | 4a0dc0068ac1a3708a8314c6d1586d20 MD5 | raw file
  1. using FluentAssertions;
  2. using MusicStore.Api;
  3. using MusicStore.Api.CommandHandlers;
  4. using MusicStore.Api.Controllers;
  5. using MusicStore.Api.Models;
  6. using NUnit.Framework;
  7. using Simple.Data;
  8. using System;
  9. using System.Web.Http.SelfHost;
  10. namespace MusicStore.UnitTest
  11. {
  12. [TestFixture]
  13. public class AddProductCommandUnitTest
  14. {
  15. [Test]
  16. public void Should_be_Able_to_Add_the_Product()
  17. {
  18. var baseAddress = new Uri("http://localhost:8082/");
  19. var httpSelfhostConfiguration = new HttpSelfHostConfiguration(baseAddress);
  20. new MusicStoreBootStrap(httpSelfhostConfiguration).ConfigureDatabaseForTest();
  21. AddProductCommand command = new AddProductCommand { Name = "Reebok Shoe", Categories = "Shoes", Id = 1 };
  22. ICommandHandler<AddProductCommand> productCommand = new AddProductCommandHandler();
  23. productCommand.Execute(command);
  24. ProductViewModel ViewModel = Database.Open().Products.FindById(1);
  25. ViewModel.Name.Should().Be(command.Name);
  26. }
  27. }
  28. }