public async Task FilterByTitlePartial()
        {
            var overrides = new Dictionary <string, object> {
                { "Title", Title }
            };

            Service.Notifications = NotificationFactory.GetFactory().Generate(20);
            Service.Notifications.AddRange(NotificationFactory.GetFactory(overrides, 21).Generate(30));

            var query1 = new SearchQueryNotification {
                Title = Title.Split(" ").Last()
            };
            var response1 = await Controller.Search(query1);

            var query2 = new SearchQueryNotification {
                Title = Title.Split(" ").First()
            };
            var response2 = await Controller.Search(query2);

            var query3 = new SearchQueryNotification {
                Title = Title.Substring(2, Title.Length - 3)
            };
            var response3 = await Controller.Search(query3);

            CustomAssert.AssertOkResponseCount(response1, 30);
            CustomAssert.AssertOkResponseCount(response2, 30);
            CustomAssert.AssertOkResponseCount(response3, 30);
        }
        public async Task FilterByTitleNoneExisting()
        {
            Service.Notifications = NotificationFactory.GetFactory().Generate(40);

            var query = new SearchQueryNotification {
                Title = Title
            };
            var response = await Controller.Search(query);

            CustomAssert.AssertOkResponseCount(response, 0);
        }
        public async Task FilterByTitleNullWhitespace(string title)
        {
            Service.Notifications = NotificationFactory.GetFactory().Generate(30);

            var query = new SearchQueryNotification {
                Title = title
            };
            var response = await Controller.Search(query);

            CustomAssert.AssertOkResponseCount(response, 30);
        }
        public async Task FilterByTitleExisting()
        {
            var overrides = new Dictionary <string, object> {
                { "Title", Title }
            };

            Service.Notifications = NotificationFactory.GetFactory().Generate(20);
            Service.Notifications.AddRange(NotificationFactory.GetFactory(overrides, 21).Generate(30));

            var query = new SearchQueryNotification {
                Title = Title
            };
            var response = await Controller.Search(query);

            CustomAssert.AssertOkResponseCount(response, 30);
        }
        public async Task NoQuerySearchNotification(int resultCount)
        {
            Service.Notifications = NotificationFactory.GetFactory().Generate(resultCount);

            var query    = new SearchQueryNotification();
            var response = await Controller.Search(query);

            var result = CustomAssert.AssertOkResponseCount(response, Math.Min(DefaultTake, resultCount));

            if (resultCount > 0)
            {
                Assert.AreEqual(result.First().Id, 1);
            }
            else
            {
                Assert.AreEqual(result.Count, 0);
            }
        }
        public async Task SkipTakeNotification(int resultCount, int skip, int take)
        {
            Service.Notifications = NotificationFactory.GetFactory().Generate(resultCount);
            var expectedCount = Math.Min(resultCount - skip, take);

            expectedCount = expectedCount < 0 ? 0 : expectedCount;
            var id = Service.Notifications.Skip(skip).FirstOrDefault()?.Id;

            var query = new SearchQueryNotification {
                Skip = skip, Take = take
            };
            var response = await Controller.Search(query);

            var result = CustomAssert.AssertOkResponseCount(response, expectedCount);

            if (id.HasValue)
            {
                Assert.AreEqual(result.First().Id, id.Value);
            }
            else
            {
                Assert.AreEqual(result.Count, 0);
            }
        }