Пример #1
0
        public void GetGroceriesCommandHandlerShouldntReturnNotifications()
        {
            var _mock   = MockRepository.GenerateMock <IGroceriesRepository>();
            var command = new GetGroceriesCommand(Guid.NewGuid());

            _mock.Expect(x => x.GetById(command.Id)).Return(new Groceries(command.Id, string.Empty, 0, Enums.Unity.Grams, Enums.Category.Bakery));

            GetGroceriesCommandHandler handler = new GetGroceriesCommandHandler(_mock);
            var g = handler.Handle(command);

            Assert.AreEqual(handler.Notifications.Count, 0);
        }
        public async Task <IActionResult> GetById(Guid id)
        {
            var result = _getGroceriesCommandHandler.Handle(new GetGroceriesCommand(id));

            if (result != null)
            {
                return(await Response(result, _getGroceriesCommandHandler.Notifications));
            }
            else
            {
                return(NotFound(_getGroceriesCommandHandler.Notifications));
            }
        }