public async Task AddAsync_AddsEntity()
        {
            //Assert

            //Act
            await testedService.AddAsync(newEntity);

            //Assert
            Mock.Verify(c => c.Add(newEntity), Times.Once());
            Mock.Verify(c => c.SaveChangesAsync(It.IsAny <CancellationToken>()), Times.Once());
        }
Example #2
0
        public void AddItem(string itemName, decimal cost)
        {
            using (var context = new ApplicationDbContext(ContextOptions))
            {
                var unitOfWork  = new UnitOfWork(context);
                var itemService = new ItemService(unitOfWork, mapper);
                var itemRequest = new ItemRequest()
                {
                    ItemName = itemName,
                    Cost     = cost
                };

                var item = itemService.AddAsync(itemRequest).GetAwaiter().GetResult();

                Assert.NotNull(item);
            }
        }