daily pastebin goal
70%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 52 in 169 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private IUnitOfWork _unitOfWork;
  2.         private Data.TestContext _testContext;
  3.         [TestInitialize]
  4.         public void Init()
  5.         {
  6.             _testContext = new Data.TestContext();
  7.             _unitOfWork = new UnitOfWork(_testContext.Context);
  8.             _testContext.Client.DefaultRequestHeaders.Add("name", "test");
  9.             _testContext.Client.DefaultRequestHeaders.Add("id", "12345");
  10.         }
  11.  
  12.         [TestMethod]
  13.         public async Task Should_add_three_attributes_to_product()
  14.         {
  15.             //Arrange
  16.             _unitOfWork.Products.Add(new Product {Id = 1});
  17.             _unitOfWork.DetailApplications.Add(new DetailApplication {Id = 1});
  18.             _unitOfWork.DetailApplications.Add(new DetailApplication { Id = 2 });
  19.             _unitOfWork.DetailApplications.Add(new DetailApplication { Id = 3 });
  20.             _unitOfWork.Save();
  21.             //Act
  22.             var result = await _testContext.Client.PostAsJsonAsync("api/attributes/add", new AddProductAttributeViewModel{DetailApplicationId = 1, ProductId = 1});
  23.            await _testContext.Client.PostAsJsonAsync("api/attributes/add", new AddProductAttributeViewModel { DetailApplicationId = 2, ProductId = 1 });
  24.            await _testContext.Client.PostAsJsonAsync("api/attributes/add", new AddProductAttributeViewModel { DetailApplicationId = 3, ProductId = 1 });
  25.             //Assert
  26.             var product = _unitOfWork.Products.GetWithAttributes(1);
  27.             product.ProductAttributes.Count.Should().Be(3);
  28.             product.ProductAttributes.Should().Contain(x => x.Id == 1);
  29.             product.ProductAttributes.Should().Contain(x => x.Id == 3);
  30.         }
RAW Paste Data
Top