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);
        }
Exemplo n.º 2
0
        public async Task NoQuerySearchOwnerType()
        {
            var query    = new SearchQueryOwnerType();
            var response = await Controller.Search(query);

            CustomAssert.AssertOkResponseCount(response, 3);
        }
Exemplo n.º 3
0
        public async Task FilterByResponsiblePartial()
        {
            var overrides = new Dictionary <string, object> {
                { "Responsible", Responsible }
            };

            Service.Anomalies = AnomalityFactory.GetFactory().Generate(20);
            Service.Anomalies.AddRange(AnomalityFactory.GetFactory(overrides, 21).Generate(30));

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

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

            var query3 = new SearchQueryAnomaly {
                Responsible = Responsible.Substring(2, Responsible.Length - 5)
            };
            var response3 = await Controller.Search(query3);

            CustomAssert.AssertOkResponseCount(response1, 30);
            CustomAssert.AssertOkResponseCount(response2, 30);
            CustomAssert.AssertOkResponseCount(response3, 30);
        }
Exemplo n.º 4
0
        public async Task SearchByNameNoneExisting()
        {
            var query = new SearchQueryOwnerType {
                Name = "Test"
            };
            var response = await Controller.Search(query);

            CustomAssert.AssertOkResponseCount(response, 0);
        }
Exemplo n.º 5
0
        public async Task SearchByMinPriority()
        {
            var query = new SearchQueryOwnerType {
                MinPriority = 2
            };
            var response = await Controller.Search(query);

            CustomAssert.AssertOkResponseCount(response, 2);
        }
        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);
        }
Exemplo n.º 8
0
        public async Task FilterByResponsibleNullWhitespace(string responsible)
        {
            Service.Anomalies = AnomalityFactory.GetFactory().Generate(30);

            var query = new SearchQueryAnomaly {
                Responsible = responsible
            };
            var response = await Controller.Search(query);

            CustomAssert.AssertOkResponseCount(response, 30);
        }
Exemplo n.º 9
0
        public async Task FilterByResponsibleNoneExisting()
        {
            Service.Anomalies = AnomalityFactory.GetFactory().Generate(40);

            var query = new SearchQueryAnomaly {
                Responsible = Responsible
            };
            var response = await Controller.Search(query);

            CustomAssert.AssertOkResponseCount(response, 0);
        }
        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);
        }
Exemplo n.º 11
0
        public async Task FilterByResponsibleExisting()
        {
            var overrides = new Dictionary <string, object> {
                { "Responsible", Responsible }
            };

            Service.Anomalies = AnomalityFactory.GetFactory().Generate(20);
            Service.Anomalies.AddRange(AnomalityFactory.GetFactory(overrides, 21).Generate(30));

            var query = new SearchQueryAnomaly {
                Responsible = Responsible
            };
            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 SkipTakeDashboards(int resultCount, int skip, int take)
        {
            var expectedCount = Math.Min(resultCount - skip, take);

            expectedCount = expectedCount < 0 ? 0 : expectedCount;
            int?id;
            var userContext = new UserContext()
            {
                UserId = 1
            };
            var currentUserContext = A.Fake <ICurrentUserContext>();

            A.CallTo(() => currentUserContext.Get()).Returns(userContext);

            var controller = new DashboardController(Service, Mapper, currentUserContext, OwnerTypeService);

            using (var context = await ContextFactory.CreateDbContext())
            {
                context.Dashboards.AddRange(DashboardFactory
                                            .GetFactory(new Dictionary <string, object> {
                    { "OwnerTypeId", 1 }, { "OwnerId", userContext.UserId }
                }).Generate(resultCount));
                context.SaveChanges();

                id = context.Dashboards.Skip(skip).FirstOrDefault()?.Id;
            }



            var response =
                await controller.Search(new SearchQueryDashboard { Skip = skip, Take = take });

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

            if (id.HasValue)
            {
                Assert.AreEqual(result.First().Id, id.Value);
            }
            else
            {
                Assert.AreEqual(result.Count, 0);
            }
        }
Exemplo n.º 14
0
        public async Task FilterByResponsibleCaseInsensitive()
        {
            var overrides = new Dictionary <string, object> {
                { "Responsible", Responsible }
            };

            Service.Anomalies = AnomalityFactory.GetFactory().Generate(20);
            Service.Anomalies.AddRange(AnomalityFactory.GetFactory(overrides, 21).Generate(30));

            var query1 = new SearchQueryAnomaly {
                Responsible = Responsible.ToLower()
            };
            var response1 = await Controller.Search(query1);

            var query2 = new SearchQueryAnomaly {
                Responsible = Responsible.ToUpper()
            };
            var response2 = await Controller.Search(query2);

            CustomAssert.AssertOkResponseCount(response1, 30);
            CustomAssert.AssertOkResponseCount(response2, 30);
        }
        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);
            }
        }