public void ShouldProduceCalculateStatisticsOperationForCategoryStatisticsDto()
        {
            // Arrange
            var repositoryFactory = new VerifiableRepositoryFactory();
            var dto = new CategoryStatisticsDto
            {
                ProjectId  = 1,
                Categories = new[]
                {
                    new CategoryStatisticsDto.CategoryDto
                    {
                        CategoryId       = 2,
                        AdvertisersCount = 3,
                    }
                }
            };

            SourceDb.Has(new Bit::ProjectCategoryStatistics {
                ProjectId = 1, CategoryId = 7
            },
                         new Bit::ProjectCategoryStatistics {
                ProjectId = 2, CategoryId = 7
            });

            var metadataSource = new ImportStatisticsMetadataSource();
            IMetadataElement importStatisticsMetadata;

            if (!metadataSource.Metadata.Values.TryGetElementById(new Uri(typeof(CategoryStatisticsDto).Name, UriKind.Relative), out importStatisticsMetadata))
            {
                throw new NotSupportedException($"The aggregate of type '{typeof(CategoryStatisticsDto).Name}' is not supported.");
            }

            var importer = new StatisticsFactImporter <Bit::ProjectCategoryStatistics, CategoryStatisticsDto>(
                (ImportStatisticsMetadata <Bit::ProjectCategoryStatistics, CategoryStatisticsDto>)importStatisticsMetadata,
                Query,
                repositoryFactory.Create <Bit::ProjectCategoryStatistics>());

            // Act
            var operations = importer.Import(dto).ToArray();

            // Assert
            Assert.That(operations.Count(), Is.EqualTo(1));
            repositoryFactory.Verify <Bit::ProjectCategoryStatistics>(
                m => m.Delete(It.Is(Predicate.Match(new Bit::ProjectCategoryStatistics {
                ProjectId = 1, CategoryId = 7
            }))),
                Times.AtLeastOnce);
            repositoryFactory.Verify <Bit::ProjectCategoryStatistics>(
                m => m.Add(It.Is(Predicate.Match(new Bit::ProjectCategoryStatistics {
                ProjectId = 1, CategoryId = 2, AdvertisersCount = 3
            }))),
                Times.AtLeastOnce);
        }
        public void ShouldProduceCalculateStatisticsOperationForCategoryStatisticsDto()
        {
            // Arrange
            var repositoryFactory = new VerifiableRepositoryFactory();
            var dto = new CategoryStatisticsDto
            {
                ProjectId = 1,
                Categories = new[]
                                  {
                                      new CategoryStatisticsDto.CategoryDto
                                      {
                                          CategoryId = 2,
                                          AdvertisersCount = 3,
                                      }
                                  }
            };
            SourceDb.Has(new Bit::ProjectCategoryStatistics { ProjectId = 1, CategoryId = 7 },
                         new Bit::ProjectCategoryStatistics { ProjectId = 2, CategoryId = 7 });

            var metadataSource = new ImportStatisticsMetadataSource();
            IMetadataElement importStatisticsMetadata;
            if (!metadataSource.Metadata.Values.TryGetElementById(new Uri(typeof(CategoryStatisticsDto).Name, UriKind.Relative), out importStatisticsMetadata))
            {
                throw new NotSupportedException($"The aggregate of type '{typeof(CategoryStatisticsDto).Name}' is not supported.");
            }

            var importer = new StatisticsFactImporter<Bit::ProjectCategoryStatistics, CategoryStatisticsDto>(
                (ImportStatisticsMetadata<Bit::ProjectCategoryStatistics, CategoryStatisticsDto>)importStatisticsMetadata,
                Query,
                repositoryFactory.Create<Bit::ProjectCategoryStatistics>());

            // Act
            var operations = importer.Import(dto).ToArray();

            // Assert
            Assert.That(operations.Count(), Is.EqualTo(1));
            repositoryFactory.Verify<Bit::ProjectCategoryStatistics>(
                m => m.Delete(It.Is(Predicate.Match(new Bit::ProjectCategoryStatistics { ProjectId = 1, CategoryId = 7 }))),
                Times.AtLeastOnce);
            repositoryFactory.Verify<Bit::ProjectCategoryStatistics>(
                m => m.Add(It.Is(Predicate.Match(new Bit::ProjectCategoryStatistics { ProjectId = 1, CategoryId = 2, AdvertisersCount = 3 }))),
                Times.AtLeastOnce);
        }