示例#1
0
        public void FindByShould_CallPlaceServiceMethodFindInAddress_WhenSearchByIsAddress(string category, string searchBy, string pattern)
        {
            var placeServiceMock = new Mock <IPlaceService>();

            var service = new Services.SearchService(placeServiceMock.Object);

            service.FindBy(category, searchBy, pattern);

            placeServiceMock.Verify(s => s.FindInAddress(category, pattern));
        }
示例#2
0
        public void FindByShould_ReturnCorrectResult_WhenSearchByIsDescription(string category, string searchBy, string pattern)
        {
            var placeServiceMock = new Mock <IPlaceService>();

            var service = new Services.SearchService(placeServiceMock.Object);
            var place   = new Place()
            {
                Details = "Pesho's place"
            };
            var list = new List <Place>()
            {
                place
            };

            placeServiceMock.Setup(s => s.FindInDescription(category, pattern)).Returns(list.AsQueryable());

            var result = service.FindBy(category, searchBy, pattern);

            Assert.Contains(place, result.ToList());
        }
示例#3
0
        public void FindByShould_ReturnCorrectResult_WhenSearchByIsAddress(string category, string searchBy, string pattern)
        {
            var placeServiceMock = new Mock <IPlaceService>();

            var service = new Services.SearchService(placeServiceMock.Object);
            var address = new Address()
            {
                Street = "Pesho's street"
            };
            var place = new Place()
            {
                Address = address
            };
            var list = new List <Place>()
            {
                place
            };

            placeServiceMock.Setup(s => s.FindInAddress(category, pattern)).Returns(list.AsQueryable());

            var result = service.FindBy(category, searchBy, pattern);

            Assert.Contains(place, result.ToList());
        }