Exemplo n.º 1
0
        public async Task ReturnsInvalidGivenNullSearchString()
        {
            var result = await _searchService.GetAllIncompleteItemsAsync(null);

            Assert.Equal(Ardalis.Result.ResultStatus.Invalid, result.Status);
            Assert.Equal("searchString is required.", result.ValidationErrors.First().ErrorMessage);
        }
Exemplo n.º 2
0
        public async Task ReturnsListGivenSearchString()
        {
            var repo    = new Mock <IRepository>();
            var service = new ToDoItemSearchService(repo.Object);

            var result = await service.GetAllIncompleteItemsAsync("foo");

            Assert.Equal(Ardalis.Result.ResultStatus.Ok, result.Status);
        }
Exemplo n.º 3
0
        public async Task ReturnsInvalidGivenNullSearchString()
        {
            var repo    = new Mock <IRepository>();
            var service = new ToDoItemSearchService(repo.Object);

            var result = await service.GetAllIncompleteItemsAsync(null);

            Assert.Equal(Ardalis.Result.ResultStatus.Invalid, result.Status);
            Assert.Equal("searchString is required.", result.ValidationErrors.First().ErrorMessage);
        }
Exemplo n.º 4
0
        public async Task ReturnsErrorGivenDataAccessException()
        {
            string expectedErrorMessage = "Database not there.";
            var    repo    = new Mock <IRepository>();
            var    service = new ToDoItemSearchService(repo.Object);

            repo.Setup(r => r.ListAsync(It.IsAny <ISpecification <ToDoItem> >()))
            .ThrowsAsync(new System.Exception(expectedErrorMessage));

            var result = await service.GetAllIncompleteItemsAsync("something");

            Assert.Equal(Ardalis.Result.ResultStatus.Error, result.Status);
            Assert.Equal(expectedErrorMessage, result.Errors.First());
        }