Example #1
0
 //Search Entities
 public async Task <IEnumerable <InventoryItems> > SearchInventoryItems(List <string> lst, List <string> includeLst = null)
 {
     using (var ctx = new InventoryItemsService())
     {
         return(await ctx.GetInventoryItemsByExpressionLst(lst, includeLst).ConfigureAwait(false));
     }
 }
Example #2
0
        public void ReturnInventoryItemByItsId()
        {
            //Arrange
            //var context = GetPopulatedInMemoryDbContext();
            bool hasGetByIdBeenCalled = false;

            InventoryItem fakeInventoryItemToRetrieve = new InventoryItem()
            {
                InventoryItemId = 2,
                PartName        = "BataTest",
                PartNumber      = "BTE-321",
                OrderLeadTime   = 6,
                QuantityOnHand  = 5,
                SafetyStock     = 10,
                Created         = DateTime.Now,
                CreatedBy       = "Alfred"
            };

            Mock <IInventoryItemsRepository> mockRepo = new Mock <IInventoryItemsRepository>();

            mockRepo.Setup(m => m.GetById(It.IsAny <int>())).Callback <int>(i => { hasGetByIdBeenCalled = true; }).Returns(fakeInventoryItemToRetrieve);

            InventoryItemsService sut = new InventoryItemsService(mockRepo.Object);

            //Act
            var fakeInventoryItemReturned = sut.GetById(fakeInventoryItemToRetrieve.InventoryItemId);

            //Assert
            Assert.True(hasGetByIdBeenCalled);
            Assert.Equal(fakeInventoryItemToRetrieve.InventoryItemId, fakeInventoryItemReturned.InventoryItemId);
        }
Example #3
0
 public async Task SaveInventoryItems(InventoryItems i)
 {
     if (i == null)
     {
         return;
     }
     using (var ctx = new InventoryItemsService())
     {
         await ctx.UpdateInventoryItems(i).ConfigureAwait(false);
     }
 }
Example #4
0
        public void FailInventoryItemCreationIfPartNumberIsDuplicate()
        {
            //Arrange
            mockRepo = new Mock <IInventoryItemsRepository>();
            mockRepo.Setup(m => m.IsPartNumberDuplicate(duplicatePartNumber)).Returns(true);

            sut = new InventoryItemsService(mockRepo.Object);

            InventoryItem inventoryItemWithDuplicatePartNumber = new InventoryItem()
            {
                InventoryItemId = 1,
                PartName        = "Bat Test",
                PartNumber      = "BTG-001",
                OrderLeadTime   = 6,
                QuantityOnHand  = 4,
                SafetyStock     = 5,
                Created         = DateTime.Now,
                CreatedBy       = "Tester",
            };

            //Act
            Assert.Throws <Exception>(() => sut.CreateInventoryItem(inventoryItemWithDuplicatePartNumber));
        }