예제 #1
0
        public async Task Aggregate_Match(string collectionName, string aggregateExpression, int expectedCount)
        {
            var repo = new MongoService(_fixture.MongoClient, _fixture.Logger);

            var aggregateResult = await repo.AggregateAsync("bookstore", collectionName, aggregateExpression);

            var array = JArray.Parse(aggregateResult.Value);

            Assert.Equal(200, aggregateResult.Status);
            Assert.Equal(expectedCount, array.Count);
        }
예제 #2
0
        public async Task Aggregate_Count(string collectionName, string aggregateExpression, string propertyName, int expectedCount)
        {
            IObjectService service = new MongoService(_fixture.MongoClient, _fixture.Logger);

            var aggregateResult = await service.AggregateAsync("bookstore", collectionName, aggregateExpression);

            Assert.Equal(200, aggregateResult.Status);

            JToken token      = JArray.Parse(aggregateResult.Value).FirstOrDefault();
            var    countValue = token[propertyName].ToString();

            Assert.Equal(expectedCount, int.Parse(countValue));
        }