Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        public async Task NoQuerySearchAnomalies(int resultCount)
        {
            Service.Anomalies = AnomalityFactory.GetFactory().Generate(resultCount);

            var query    = new SearchQueryAnomaly();
            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);
            }
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        public async Task SkipTakeAnomalies(int resultCount, int skip, int take)
        {
            Service.Anomalies = AnomalityFactory.GetFactory().Generate(resultCount);
            var expectedCount = Math.Min(resultCount - skip, take);

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

            var query = new SearchQueryAnomaly {
                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);
            }
        }