public async Task CanQueryByChild()
        {
            var parent = ParentGenerator.Default;

            parent = await _parentRepository.AddAsync(parent);

            Assert.NotNull(parent?.Id);

            var child = ChildGenerator.Default;

            child = await _childRepository.AddAsync(child);

            Assert.NotNull(child?.Id);

            await _childRepository.AddAsync(ChildGenerator.Generate(parentId: parent.Id));

            await _client.RefreshAsync();

            Assert.Equal(2, await _childRepository.CountAsync());

            await _client.RefreshAsync();

            var parentResults = await _parentRepository.QueryAsync(new MyAppQuery().WithChildQuery(q => q.WithType("child").WithFilter("id:" + child.Id)));

            Assert.Equal(1, parentResults.Total);
        }
        public async Task GetByIds()
        {
            var parent1 = ParentGenerator.Generate();

            parent1 = await _parentRepository.AddAsync(parent1, o => o.ImmediateConsistency());

            Assert.NotNull(parent1?.Id);

            var child1 = ChildGenerator.Generate(parentId: parent1.Id);

            child1 = await _childRepository.AddAsync(child1, o => o.ImmediateConsistency());

            Assert.NotNull(child1?.Id);

            var parent2 = ParentGenerator.Generate();

            parent2 = await _parentRepository.AddAsync(parent2, o => o.ImmediateConsistency());

            Assert.NotNull(parent2?.Id);

            var child2 = ChildGenerator.Generate(parentId: parent2.Id);

            child2 = await _childRepository.AddAsync(child2, o => o.ImmediateConsistency());

            Assert.NotNull(child2?.Id);

            var ids = new Ids(child1.Id, child2.Id);

            var results = await _childRepository.GetByIdsAsync(ids);

            Assert.NotNull(results);
            Assert.Equal(2, results.Count);

            var idsWithRouting = new Ids(new Id(child1.Id, parent1.Id), new Id(child2.Id, parent2.Id));

            var resultsWithRouting = await _childRepository.GetByIdsAsync(idsWithRouting);

            Assert.NotNull(resultsWithRouting);
            Assert.Equal(2, resultsWithRouting.Count);
        }
Example #3
0
        public async Task CanQueryByChild()
        {
            var parent = ParentGenerator.Default;

            parent = await _parentRepository.AddAsync(parent, o => o.ImmediateConsistency());

            Assert.NotNull(parent?.Id);

            var child = ChildGenerator.Default;

            child = await _childRepository.AddAsync(child, o => o.ImmediateConsistency());

            Assert.NotNull(child?.Id);

            await _childRepository.AddAsync(ChildGenerator.Generate(parentId: parent.Id), o => o.ImmediateConsistency());

            Assert.Equal(2, await _childRepository.CountAsync());

            var parentResults = await _parentRepository.QueryAsync(q => q.ChildQuery(typeof(Child), c => c.FilterExpression("id:" + child.Id)));

            Assert.Equal(1, parentResults.Total);
        }