コード例 #1
0
        public void When_adding_facet_filter_then_it_is_added_in_context()
        {
            this._questionsServiceMock  = new Mock <IQuestionsService>();
            this._suggestionServiceMock = new Mock <ISuggestionsService>();

            var facet = FacetBuilder.Build
                        .WithName("Year")
                        .AddValue("2018")
                        .Instance;

            var query = FilterQueryBuilder.Build
                        .WithFacet(facet)
                        .Instance;

            this._nlpServiceMock = new Mock <INlpCall>();

            this._suggestionController = new SuggestionsController(this._suggestionServiceMock.Object, this._questionsServiceMock.Object, this._nlpServiceMock.Object, this._contexts);

            this._suggestionController.OnActionExecuting(this.GetActionExecutingContext(query));
            this._suggestionController.AddFilter(query);

            var context =
                this._suggestionController.GetType().BaseType
                .GetProperty("ConversationContext", BindingFlags.NonPublic | BindingFlags.Instance)
                .GetValue(this._suggestionController) as ConversationContext;

            context.MustHaveFacets.Should().HaveCount(1);
            context.MustHaveFacets.Single().Should().BeEquivalentTo(facet);
        }
コード例 #2
0
        public void When_removing_facet_filter_then_it_is_removed_in_context()
        {
            this._questionsServiceMock  = new Mock <IQuestionsService>();
            this._suggestionServiceMock = new Mock <ISuggestionsService>();

            var facet = FacetBuilder.Build
                        .WithName("Year")
                        .WithValue("2018")
                        .Instance;

            var query = FilterQueryBuilder.Build
                        .WithFacet(facet)
                        .Instance;

            this._suggestionController = new SuggestionsController(this._suggestionServiceMock.Object, this._questionsServiceMock.Object, this._contexts);

            this._suggestionController.OnActionExecuting(this.GetActionExecutingContext(query));
            this._suggestionController.AddFilter(query);

            this._suggestionController.RemoveFilter(query);

            var context =
                this._suggestionController.GetType().BaseType
                .GetProperty("ConversationContext", BindingFlags.Public | BindingFlags.Instance)
                .GetValue(this._suggestionController) as ConversationContext;

            context.FilterDocumentsParameters.MustHaveFacets.Should().HaveCount(0);
        }
コード例 #3
0
        public void DosageSchemeTestSuitable()
        {
            //Test that a new suggestion is added to the user. PS! E-mail sending can not be currently tested functionally.
            // Arrange
            controller = SetupController();
            persons.Setup(repo => repo.GetPersonByIDCode(patient.IDCode)).ReturnsAsync(new PersonObject(patient));
            personMedicines.Setup(repo => repo.GetObject("123", "abc"))
            .ReturnsAsync(new PersonMedicineObject(new PersonMedicineDbRecord())
            {
                Medicine = { }, Person = { }
            });
            personMedicines.Setup(repo => repo.AddObject(It.IsAny <PersonMedicineObject>())).Returns <PersonMedicineObject>(fg => AddPerMed(fg));
            medicines.Setup(repo => repo.GetObject("123")).ReturnsAsync(new MedicineObject(medicine));

            // Act
            var x           = medicines.Object.GetObjectsList();
            var result      = controller.DosageScheme(suggestionViewModel, "123", "");
            var resultPrior = controller.DosageScheme(suggestionViewModel, "123", "prior");


            // Assert
            Assert.IsInstanceOfType(result.Result, typeof(RedirectToActionResult));
            Assert.AreEqual(2, personMedObjects.Count);
            Assert.AreEqual(personMedObjects[0].Person.DbRecord.IDCode, patient.IDCode);
            Assert.AreEqual(personMedObjects[0].Medicine.DbRecord.ID, medicine.ID);
        }
コード例 #4
0
        public void ShouldAddSuggestion()
        {
            // Arrange
            var mockSuggestionRepository = new Mock <ISuggestionRepository>();

            mockSuggestionRepository.Setup(x => x.Get(42))
            .Returns(value: null);
            var        mockBookingReposiroty = new Mock <IBookingRepository>();
            Suggestion sugg = new Suggestion()
            {
                Id            = 42,
                UserId        = 1,
                Name          = "dit is een suggestie",
                NumberOfHours = 8.0,
                Description   = "dit is een beschrijving",
                Milestone     = "dit is een milestone",
                Type          = BookingType.Training
            };

            var sut = new SuggestionsController(mockSuggestionRepository.Object, mockBookingReposiroty.Object);

            // Act
            IActionResult actionResult = sut.AddSuggestion(sugg, 1);

            // Assert
            Assert.IsNotNull(actionResult);
            mockSuggestionRepository.Verify(mock => mock.Get(42));
            mockSuggestionRepository.Verify(mock => mock.Add(sugg), Times.Once);
        }
コード例 #5
0
        public void ShouldUpdateSuggestion()
        {
            // Arrange
            var mockSuggestionRepository = new Mock <ISuggestionRepository>();

            mockSuggestionRepository.Setup(x => x.Get(42))
            .Returns(new Suggestion {
                Id = 42
            });
            var        mockBookingReposiroty = new Mock <IBookingRepository>();
            Suggestion sugg = new Suggestion()
            {
                UserId        = 1,
                Id            = 42,
                Name          = "Dit is een suggestie",
                NumberOfHours = 8.0,
                Description   = "dit is een beschrijving",
                Milestone     = "dit is een milestone",
                Type          = BookingType.Training
            };

            var sut = new SuggestionsController(mockSuggestionRepository.Object, mockBookingReposiroty.Object);

            // Act
            IActionResult actionResult = sut.UpdateSuggestion(42, sugg, 1);

            // Assert
            Assert.IsNotNull(actionResult);
            // TODO: mockSuggestionRepository.Verify(mock => mock.Get(42));
            // Passes but is wrong: mockSuggestionRepository.Verify(mock => mock.Update(1, sugg), Times.Once);
            mockSuggestionRepository.Verify(mock => mock.Update(42, sugg), Times.Once);
        }
コード例 #6
0
        public void When_receive_valid_searchQuery_then_return_Ok_request(int validQueryIndex)
        {
            var suggestionFromService = new Suggestion
            {
                Questions = GetListOfQuestions().Select(QuestionToClient.FromQuestion).ToList(),
                Documents = GetListOfDocuments()
            };

            this._suggestionServiceMock = new Mock <ISuggestionsService>();
            var query = this._validSearchQueryList[validQueryIndex];

            this._suggestionServiceMock
            .Setup(x => x.GetNewSuggestion(It.IsAny <ConversationContext>(), query))
            .Returns(suggestionFromService);

            this._questionsServiceMock = new Mock <IQuestionsService>();

            this._suggestionController = new SuggestionsController(this._suggestionServiceMock.Object, this._questionsServiceMock.Object, this._contexts);

            this._suggestionController.OnActionExecuting(this.GetActionExecutingContext(query));

            var result = this._suggestionController.GetSuggestions(query);

            var suggestion = result.As <OkObjectResult>().Value as Suggestion;

            suggestion.Should().NotBeNull();
            suggestion?.Documents.Should().BeEquivalentTo(suggestionFromService.Documents);
            suggestion?.Questions.Should().BeEquivalentTo(suggestionFromService.Questions);
        }
        public void SetUp()
        {
            this._cityRepositoryMock = new Mock <ICityRepository>();

            var suggestionsService = new SuggestionsService(this._cityRepositoryMock.Object);

            this._suggestionsController = new SuggestionsController(suggestionsService);
        }
コード例 #8
0
        public SuggestionsControllerTests()
        {
            userRepository       = new Mock <IUserRepository>();
            suggesionsRepository = new Mock <ISuggestionsRepository>();
            sessionService       = new Mock <ISessionService>();

            subject = new SuggestionsController(userRepository.Object, sessionService.Object, suggesionsRepository.Object);
        }
コード例 #9
0
        public void Mock_GetViewResultIndex_Test()
        {
            //Arrange
            DbSetup();
            SuggestionsController controller = new SuggestionsController(mock.Object);
            //Act
            var result = controller.Index();

            //Assert
            Assert.IsType <ViewResult>(result);
        }
コード例 #10
0
        public void Mock_IndexListOfSuggestions_Test()
        {
            //Arrange
            DbSetup();
            ViewResult indexView = new SuggestionsController(mock.Object).Index() as ViewResult;
            //Act
            var result = indexView.ViewData.Model;

            //Assert
            Assert.IsType <List <Suggestion> >(result);
        }
コード例 #11
0
        public void Get_ModelListSuggestionIndex_Test()
        {
            //Arrange
            ViewResult indexView = new SuggestionsController(mock.Object).Index() as ViewResult;

            //Act
            var result = indexView.ViewData.Model;

            //Assert
            Assert.IsType <List <Suggestion> >(result);
        }
コード例 #12
0
        public void Get_ViewIndex_Test()
        {
            //Arrange
            SuggestionsController controller = new SuggestionsController(db);

            //Act
            IActionResult result = controller.Index();

            //Assert
            Assert.IsType <ViewResult>(result);
        }
コード例 #13
0
        public void DosageSchemeTestNotSuitable()
        {
            //Test that a new suggestion is added to the user. PS! E-mail sending can not be currently tested functionally.
            // Arrange
            controller = SetupController();
            medicines.Setup(repo => repo.GetObjectsList())
            .ReturnsAsync(new MedicineObjectsList(new List <MedicineDbRecord>(), new RepositoryPage(0)));
            persons.Setup(repo => repo.GetPersonByIDCode(patient.IDCode)).ReturnsAsync(new PersonObject(patient));
            personMedicines.Setup(repo => repo.GetObject("123", "abc"))
            .ReturnsAsync(new PersonMedicineObject(new PersonMedicineDbRecord()
            {
                Suitability = Suitability.Jah
            })
            {
                Medicine = { }, Person = { }
            });
            personMedicines.Setup(repo => repo.AddObject(It.IsAny <PersonMedicineObject>())).Returns <PersonMedicineObject>(fg => AddPerMed(fg));
            medicines.Setup(repo => repo.GetObject("123")).ReturnsAsync(new MedicineObject(medicine));

            // Act
            var x      = medicines.Object.GetObjectsList();
            var result = controller.DosageScheme(suggestionViewModel, "123", "");

            //Change suitability to "no", meaning user will not get a suggestion unless "prior" is passed into the controller.
            personMedicines.Setup(repo => repo.GetObject("123", "abc"))
            .ReturnsAsync(new PersonMedicineObject(new PersonMedicineDbRecord()
            {
                Suitability = Suitability.Ei
            })
            {
                Medicine = { }, Person = { }
            });

            var resultPrior     = controller.DosageScheme(suggestionViewModel, "123", "prior");
            var resultPriorFail = controller.DosageScheme(suggestionViewModel, "123", "");

            //Suitability stays the same, "no", but medicine that is suggested, has already been suggested to the user before.
            //Triggers additional blocks in code.
            personMedicines.Setup(repo => repo.GetObject("123", "abc"))
            .ReturnsAsync(new PersonMedicineObject(new PersonMedicineDbRecord()
            {
                Suitability = Suitability.Ei, Medicine = medicine
            }));
            var resultsFinalPrior = controller.DosageScheme(suggestionViewModel, "123", "prior");
            var resultsFinal      = controller.DosageScheme(suggestionViewModel, "123", "");

            // Assert
            //Check that only the correct amount of suggestions were added to the suggestions database.
            Assert.IsInstanceOfType(result.Result, typeof(RedirectToActionResult));
            Assert.AreEqual(3, personMedObjects.Count);
            Assert.AreEqual(personMedObjects[0].Person.DbRecord.IDCode, patient.IDCode);
            Assert.AreEqual(personMedObjects[0].Medicine.DbRecord.ID, medicine.ID);
        }
コード例 #14
0
        public void DB_CreateNewEntry_Test()
        {
            // Arrange
            SuggestionsController controller     = new SuggestionsController(db);
            Suggestion            testSuggestion = new Suggestion();

            testSuggestion.Description = "TestDb Suggestion";

            // Act
            controller.Create(testSuggestion);
            var collection = (controller.Index() as ViewResult).ViewData.Model as IEnumerable <Suggestion>;

            // Assert
            Assert.Contains <Suggestion>(testSuggestion, collection);
        }
コード例 #15
0
        public void Get_ViewCreate_Test()
        {
            //Arrange
            Location location = new Location();

            location.LocationName = "Testland";
            db.Save(location);
            SuggestionsController controller = new SuggestionsController(db);

            //Act
            IActionResult result = controller.Create(location.LocationId);

            //Assert
            Assert.IsType <ViewResult>(result);
        }
コード例 #16
0
        public void Db_AddSuggestion_Test()
        {
            //Arrange
            SuggestionsController controller = new SuggestionsController(this.repoWithTestDBContext);

            new Suggestion {
                Id = 1, City = "Borihg", Country = "USA", Description = "Fun places"
            };

            //Act
            var addSuggestionView = controller.AddSuggestion("Boring", "USA", "Fun place");// as ViewResult;

            //Assert
            Assert.True(true);
        }
コード例 #17
0
        public void Mock_ConfirmUpvote_Test()
        {
            //AAAARRRRANNNNNGGEEE
            SuggestionsController controller     = new SuggestionsController(db);
            Suggestion            testSuggestion = new Suggestion();

            testSuggestion.Votes = 1;

            // Aaaaaaaaaaaaaaaaaaaaaaaaact
            db.Save(testSuggestion);
            db.Upvote(testSuggestion);

            // Aaaaaaaaaaaaaasserrrrt
            Assert.Equal(2, testSuggestion.Votes);
        }
コード例 #18
0
        public void Mock_ConfirmEntry_Test()
        {
            //Arrange
            DbSetup();
            SuggestionsController controller = new SuggestionsController(mock.Object);
            var testItem = new Suggestion {
                Id = 1, City = "Portland", Country = "United States", Description = "The City of Roses"
            };
            //Act
            ViewResult indexView  = controller.Index() as ViewResult;
            var        collection = indexView.ViewData.Model as IEnumerable <Suggestion>;

            // Assert
            Assert.Contains <Suggestion>(testItem, collection);
        }
コード例 #19
0
        public void When_receive_invalid_or_null_selectQuery_then_return_bad_request(int invalidQueryIndex)
        {
            this._suggestionServiceMock = new Mock <ISuggestionsService>();
            this._suggestionServiceMock
            .Setup(x => x.UpdateContextWithSelectedSuggestion(It.IsAny <ConversationContext>(), new Guid("c21d07d5-fd5a-42ab-ac2c-2ef6101e58d1")))
            .Returns(false);

            SelectQuery query = this._invalidSelectQueryList[invalidQueryIndex];

            this._questionsServiceMock = new Mock <IQuestionsService>();
            this._suggestionController = new SuggestionsController(this._suggestionServiceMock.Object, this._questionsServiceMock.Object, this._contexts);
            var actionContext = this.GetActionExecutingContext(query);

            this._suggestionController.OnActionExecuting(actionContext);
            actionContext.Result.Should().BeOfType <BadRequestObjectResult>();
        }
コード例 #20
0
        public void When_receive_valid_selectQuery_then_return_Ok_request(int validQueryIndex)
        {
            this._suggestionServiceMock = new Mock <ISuggestionsService>();
            this._suggestionServiceMock
            .Setup(x => x.UpdateContextWithSelectedSuggestion(It.IsAny <ConversationContext>(), this._validSelectQueryList[validQueryIndex].Id.Value))
            .Returns(true);

            SelectQuery query = this._invalidSelectQueryList[validQueryIndex];

            this._questionsServiceMock = new Mock <IQuestionsService>();

            this._suggestionController = new SuggestionsController(this._suggestionServiceMock.Object, this._questionsServiceMock.Object, this._contexts);

            this._suggestionController.OnActionExecuting(this.GetActionExecutingContext(query));
            this._suggestionController.SelectSuggestion(this._validSelectQueryList[validQueryIndex]).Should().BeEquivalentTo(new OkResult());
        }
コード例 #21
0
        public async Task ReturnNothingWhenNothingIsGivenAsTheRechercheCriteria()
        {
            // mock prep
            var mockService = new Mock <ISuggestionService>();

            // Declaration and call to the controller
            var        controller = new SuggestionsController(mockService.Object);
            JsonResult result     = await controller.Get();

            // Tests
            Assert.IsType <Suggestions>(result.Value);

            Suggestions resultObject = (Suggestions)result.Value;

            Assert.Equal(0, resultObject.ListSuggestion.Count);
        }
コード例 #22
0
        public void Mock_ConfirmEntry_Test() //Confirms presence of known entry
        {
            // Arrange
            DbSetup();
            SuggestionsController controller     = new SuggestionsController(mock.Object);
            Suggestion            testSuggestion = new Suggestion();

            testSuggestion.Description  = "Its.. France";
            testSuggestion.SuggestionId = 1;

            // Act
            ViewResult indexView  = controller.Index() as ViewResult;
            var        collection = indexView.ViewData.Model as IEnumerable <Suggestion>;

            // Assert
            Assert.Contains <Suggestion>(testSuggestion, collection);
        }
コード例 #23
0
        public void When_receive_invalid_or_null_searchQuery_then_return_bad_request(int invalidQueryIndex)
        {
            this._suggestionServiceMock = new Mock <ISuggestionsService>();
            this._suggestionServiceMock
            .Setup(x => x.GetDocuments(It.IsAny <ConversationContext>()))
            .Returns(GetListOfDocuments());

            this._questionsServiceMock = new Mock <IQuestionsService>();

            this._suggestionController = new SuggestionsController(this._suggestionServiceMock.Object, this._questionsServiceMock.Object, this._contexts);

            SearchQuery query = this._invalidSearchQueryList[invalidQueryIndex];

            var actionContext = this.GetActionExecutingContext(query);

            this._suggestionController.OnActionExecuting(actionContext);
            actionContext.Result.Should().BeOfType <BadRequestObjectResult>();
        }
コード例 #24
0
        public void ShouldNotDeleteSuggestionWithId24()
        {
            // Arrange
            var mockSuggestionRepository = new Mock <ISuggestionRepository>();

            mockSuggestionRepository.Setup(x => x.Get(24))
            .Returns(value: null);
            var mockBookingReposiroty = new Mock <IBookingRepository>();

            var sut = new SuggestionsController(mockSuggestionRepository.Object, mockBookingReposiroty.Object);

            // Act
            ActionResult actionResult = sut.DeleteSuggestion(24);

            // Assert
            Assert.IsNotNull(actionResult);
            mockSuggestionRepository.Verify(mock => mock.Get(24));
            mockSuggestionRepository.Verify(mock => mock.Delete(24), Times.Never);
        }
コード例 #25
0
        public void ShouldNotGetSuggestionWithId24()
        {
            // Arrange
            var mockSuggestionRepository = new Mock <ISuggestionRepository>();

            mockSuggestionRepository.Setup(x => x.Get(24))
            .Returns(value: null);
            var mockBookingReposiroty = new Mock <IBookingRepository>();

            var sut = new SuggestionsController(mockSuggestionRepository.Object, mockBookingReposiroty.Object);

            // Act
            ActionResult <Suggestion> actionResult = sut.GetSuggestion(24);
            Suggestion resultValue = actionResult.Value;

            // Assert
            Assert.IsNotNull(actionResult);
            Assert.IsNull(resultValue);
        }
コード例 #26
0
        public void ShouldDeleteSuggestionWithId42()
        {
            // Arrange
            var mockSuggestionRepository = new Mock <ISuggestionRepository>();

            mockSuggestionRepository.Setup(x => x.Get(42))
            .Returns(new Suggestion {
                Id = 42
            });
            var mockBookingReposiroty = new Mock <IBookingRepository>();

            var sut = new SuggestionsController(mockSuggestionRepository.Object, mockBookingReposiroty.Object);

            // Act
            ActionResult actionResult = sut.DeleteSuggestion(42);

            // Assert
            Assert.IsNotNull(actionResult);
            mockSuggestionRepository.Verify(mock => mock.Get(42));
            mockSuggestionRepository.Verify(mock => mock.Delete(42), Times.Once);
        }
コード例 #27
0
        public void ShouldGetSuggestionWithId42()
        {
            // Arrange
            var mockSuggestionRepository = new Mock <ISuggestionRepository>();

            mockSuggestionRepository.Setup(x => x.Get(42))
            .Returns(new Suggestion {
                Id = 42
            });
            var mockBookingReposiroty = new Mock <IBookingRepository>();

            var sut = new SuggestionsController(mockSuggestionRepository.Object, mockBookingReposiroty.Object);

            // Act
            ActionResult <Suggestion> actionResult = sut.GetSuggestion(42);

            // Assert
            Assert.IsNotNull(actionResult);
            mockSuggestionRepository.Verify(mock => mock.Get(42));
            Assert.IsInstanceOfType(actionResult, typeof(ActionResult <Suggestion>));
        }
コード例 #28
0
        public void DB_ViewIndex_Test()
        {
            // Arrange
            SuggestionsController controller     = new SuggestionsController(db);
            Suggestion            testSuggestion = new Suggestion();

            testSuggestion.Description = "So quiet.";

            Location testLocation = new Location();

            testLocation.LocationName = "New Mexico";
            db.Save(testLocation);

            // Act
            controller.Create(testSuggestion, testLocation.LocationId);
            ViewResult indexView = new SuggestionsController().Index() as ViewResult;
            IEnumerable <Suggestion> collection = (controller.Index() as ViewResult).ViewData.Model as IEnumerable <Suggestion>;

            // Assert
            Assert.Contains(testSuggestion, collection);
        }
コード例 #29
0
        public void SetUp()
        {
            this._indexSearchHttpMessageHandleMock        = new Mock <HttpMessageHandler>();
            this._lastClickAnalyticsHttpMessageHandleMock = new Mock <HttpMessageHandler>();
            this._nearestDocumentsHttpMessageHandleMock   = new Mock <HttpMessageHandler>();
            this._nlpCallHttpMessageHandleMock            = new Mock <HttpMessageHandler>();
            this._documentFacetsHttpMessageHandleMock     = new Mock <HttpMessageHandler>();
            this._filterDocumentsHttpMessageHandleMock    = new Mock <HttpMessageHandler>();

            var indexSearchHttpClient        = new HttpClient(this._indexSearchHttpMessageHandleMock.Object);
            var lastClickAnalyticsHttpClient = new HttpClient(this._lastClickAnalyticsHttpMessageHandleMock.Object);
            var nearestDocumentsHttpClient   = new HttpClient(this._nearestDocumentsHttpMessageHandleMock.Object);
            var nlpCallHttpClient            = new HttpClient(this._nlpCallHttpMessageHandleMock.Object);
            var documentFacetHttpClient      = new HttpClient(this._documentFacetsHttpMessageHandleMock.Object);
            var filterDocumentsHttpClient    = new HttpClient(this._filterDocumentsHttpMessageHandleMock.Object);

            var indexSearch        = new IndexSearch(null, this._numberOfResults, indexSearchHttpClient, "https://localhost:5000", null);
            var lastClickAnalytics = new LastClickAnalytics(lastClickAnalyticsHttpClient, "https://localhost:5000");
            var nearestDocuments   = new NearestDocuments(nearestDocumentsHttpClient, "https://localhost:5000");
            var nlpCall            = new NlpCall(nlpCallHttpClient, this.GetIrrelevantIntents(), "https://localhost:5000", 0.5);
            var documentFacets     = new DocumentFacets(documentFacetHttpClient, "https://localhost:5000");
            var filterDocuments    = new FilterDocuments(filterDocumentsHttpClient, "https://localhost:5000");

            this._recommenderSettings = new RecommenderSettings
            {
                UseAnalyticsSearchRecommender         = false,
                UseFacetQuestionRecommender           = true,
                UseLongQuerySearchRecommender         = true,
                UsePreprocessedQuerySearchRecommender = false,
                UseNearestDocumentsRecommender        = false
            };

            var suggestionsService = new SuggestionsService(indexSearch, lastClickAnalytics, documentFacets, nearestDocuments, filterDocuments, 7, 0.5, this._recommenderSettings);

            var contexts         = new InMemoryContexts(new TimeSpan(1, 0, 0, 0));
            var questionsService = new QuestionsService();

            this._suggestionController = new SuggestionsController(suggestionsService, questionsService, nlpCall, contexts);
        }
コード例 #30
0
        public async Task ReturnSomethingWhateverWeGive(string dataFromTheory)
        {
            // variables used for the MOCK
            var search = new Search(dataFromTheory);

            search.Latitude  = 0m;
            search.Longitude = 0m;

            var suggestions = new Suggestions();

            suggestions.ListSuggestion = new List <Suggestions.Suggestion>();

            suggestions.ListSuggestion.Add(new Suggestions.Suggestion {
                Name      = "wordwithana",
                Latitude  = "1.1",
                Longitude = "1.1",
                Score     = 1
            });

            // Configure the mock of the service to return what we want for the test
            // TODO: Doesnt work now, GetLocations is not overloaded, locations return nothing
            // and crashs the test
            var mockService = new Mock <ISuggestionService>();

            mockService.Setup(repo => repo.GetSuggestions(search))
            .Returns(Task.FromResult(suggestions));

            // Declaration and call to the controller
            var        controller = new SuggestionsController(mockService.Object);
            JsonResult result     = await controller.Get(dataFromTheory);

            // tests
            Assert.IsType <Suggestions>(result.Value);

            Suggestions resultObject = (Suggestions)result.Value;

            Assert.Equal(1, resultObject.ListSuggestion.Count);
        }