예제 #1
0
        public async Task CallRepositoryWhenHandling()
        {
            var handler = new ToDoItemsQueryHandler(_mockToDoRepository.Object);
            await handler
            .Handle(new ToDoItemsQuery(new AllToDoItems()), new System.Threading.CancellationToken())
            .ConfigureAwait(false);

            _mockToDoRepository.Verify(x => x.GetItemsAsync(It.IsAny <ICacheableDataSpecification <ToDoItem> >()), Times.Once);
        }
예제 #2
0
        public async Task CallRepositoryWhenHandling()
        {
            var handler = new ToDoItemsQueryHandler(_mockToDoRepository.Object);
            await handler
            .Handle(new ToDoItemsQuery(new AllToDoItems()), new System.Threading.CancellationToken())
            .ConfigureAwait(false);

            _mockToDoRepository.Verify(x => x.GetAsync(It.IsAny <Expression <Func <ToDoItem, bool> > >()), Times.Once);
        }
예제 #3
0
        public async Task ReturnToDoItem()
        {
            var handler  = new ToDoItemsQueryHandler(_mockToDoRepository.Object);
            var response = await handler
                           .Handle(new ToDoItemsQuery(new AllToDoItems()), new System.Threading.CancellationToken())
                           .ConfigureAwait(false);

            response.Should().NotBeNull();
            response.Should().NotBeNullOrEmpty()
            .And.HaveCount(6);
        }
예제 #4
0
        public async Task ReturnSuccessFalseOnError()
        {
            var mockRepo = new Mock <IRepository <ToDoItem> >();

            mockRepo
            .Setup(x => x.GetItemsAsync(It.IsAny <ICacheableDataSpecification <ToDoItem> >()))
            .ThrowsAsync(new System.Exception("Error"))
            .Verifiable();

            var handler = new ToDoItemsQueryHandler(mockRepo.Object);
            var result  = await handler
                          .Handle(new ToDoItemsQuery(new AllToDoItems()), new System.Threading.CancellationToken())
                          .ConfigureAwait(false);

            mockRepo.Verify(x => x.GetItemsAsync(It.IsAny <ICacheableDataSpecification <ToDoItem> >()), Times.Once);
            result.Should().BeNull();
        }