Esempio n. 1
0
        public async void SearchFormAsync_ExistingData_ReturnsForm()
        {
            // Arrange
            var input = new SearchFormInput
            {
                Request = "John"
            };
            var forms = new List <Form>
            {
                new Form {
                    Json = "\"name\":\"John\""
                }
            };

            var repo = new Mock <IFormRepository>(MockBehavior.Strict);

            repo.Setup(s => s.FindAsync(It.Is <string>(s => s == input.Request)))
            .ReturnsAsync(forms);
            var uow = new Mock <IUnitOfWork>(MockBehavior.Strict);

            uow
            .Setup(s => s.Forms)
            .Returns(repo.Object);
            uow
            .Setup(s => s.Dispose());

            var service = new FormService(uow.Object);

            // Act
            var output = await service.SearchFormAsync(input);

            // Assert
            Assert.True(output.Result.Count == 1);
            Assert.Equal(forms.First().Json, output.Result.First());
        }
Esempio n. 2
0
        public async Task <SearchFormOutput> SearchFormAsync(SearchFormInput input)
        {
            var result = await _unit.Forms.FindAsync(input.Request);

            return(_mapper.Map <SearchFormOutput>(result));
        }
Esempio n. 3
0
        public async Task <IActionResult> SearchFormAsync(SearchFormInput input)
        {
            var output = await _formService.SearchFormAsync(input);

            return(Ok(output));
        }