public void GetByPartId_ValidId_ReturnsPart()
        {
            var part = _partService.GetById(ValidPartId);

            Assert.IsInstanceOfType(part, typeof(Part));
            Assert.AreEqual(part.PartId, ValidPartId);
            Assert.AreEqual(part.Price, ValidPartAmount);
        }
        public ActionResult Details(int blockId)
        {
            PartService service = new PartService();
            Part        set     = service.GetById(blockId);

            return(View(set));
        }
Exemple #3
0
 public void OnGet(int partID)
 {
     Part       = PartService.GetById(partID);
     Categories = PartCategoryService.GetAll().Select(a => new SelectListItem
     {
         Value = a.CategoryID.ToString(),
         Text  = a.Title
     });
 }
        public void WhenGettingEntity_ThenReturnsCorrectEntity()
        {
            // Arrange
            var repositoryMock = new Mock<IPartRepository>();
            Part newEntity = DefaultModelHelper.DummyPopulatedPart();

            repositoryMock.Setup(repo => repo.GetById(It.IsAny<int>())).Returns(newEntity);

            // Act
            var services = new PartService(repositoryMock.Object, new Mock<IUnitOfWork>().Object);
            Part returnedEntity = services.GetById(1);

            // Assert
            Assert.NotNull(returnedEntity);
            Assert.Equal("Title", returnedEntity.Title);
        }
Exemple #5
0
        public void CreateOrderItem_validPart_addsOrderItem()
        {
            //Arrange
            var contract = _contractService.GetById(ValidContractId);
            var order    = _orderService.CreateOrder(contract);

            var part     = _partService.GetById(ValidPartId);
            var quantity = 1;

            //Act
            var orderItem = _orderService.CreateOrderItem(part, quantity);

            //Assert
            Assert.AreEqual(orderItem.Part, part);
            Assert.AreEqual(orderItem.Quantity, quantity);
            Assert.AreEqual(orderItem.Price, ValidPartPrice);
            Assert.AreEqual(orderItem.LineTotal, quantity * ValidPartPrice);
        }
        public void CreateOrderItem_ValidPart_CreatesOrderItem()
        {
            //Arrange
            var orderService = new OrderService();
            var contract     = _contractService.GetById(ValidContractId);
            var newOrder     = orderService.CreateOrder(contract);

            var partService = new PartService(_partServiceRepository);
            var part        = partService.GetById(ValidPartId);

            var quantity = 1;

            //Act
            var orderItem = orderService.CreateOrderItem(part, quantity);

            Assert.AreEqual(orderItem.Part, part);
            Assert.AreEqual(orderItem.Quantity, quantity);
            Assert.AreEqual(orderItem.Price, ValidPartPrice);
            Assert.AreEqual(orderItem.LineTotal, quantity * ValidPartPrice);
        }
Exemple #7
0
 public void GetPartById_InValidId_ReturnsPart()
 {
     var partService = new PartService(_partRepository);
     var part        = partService.GetById(InvalidPartId);
 }