Пример #1
0
        public async Task HasDataGridAudits()
        {
            // Arrange
            var kernel = IntegrationSetupFixture.CreateNewKernel();

            kernel.Bind <IServicesMgr>().ToConstant(TestUtilities.GetKeplerServicesManager());
            kernel.Bind <IHelper>().ToConstant(TestUtilities.GetMockHelper().Object);

            var workspaceId       = Config.WorkSpaceId;
            var connectionFactory = TestUtilities.GetIntegrationConnectionFactory();
            var hourRepository    = new HourRepository(connectionFactory);
            var hour = await hourRepository.ReadLatestCompletedHourAsync();

            var dataGridCacheRepositoryMock = new Mock <IDataGridCacheRepository>();

            dataGridCacheRepositoryMock.Setup(m => m.ReadUseDataGrid(workspaceId, It.IsAny <int>())).ReturnsAsync(false);

            var factory =
                new WorkspaceAuditServiceFactory(
                    new RelativityApplicationRepository(connectionFactory),
                    kernel.Get <IWorkspaceAuditServiceProvider <ISqlWorkspaceAuditService> >(),
                    kernel.Get <IWorkspaceAuditServiceProvider <IDataGridWorkspaceAuditService> >(),
                    new PdbSqlToggleProvider(connectionFactory),
                    TestUtilities.GetMockLogger().Object,
                    dataGridCacheRepositoryMock.Object);

            // Act
            var result = await factory.HasDataGridAudits(workspaceId, hour.Id);

            // Assert
            Assert.That(result, Is.True);
        }
        private static IKernel GetKernel()
        {
            var helper = TestUtilities.GetMockHelper(Config.RelativityServiceUrl, Config.RelativityRestUrl, Config.RSAPIUsername, Config.RSAPIPassword).Object;

            var agentService = Mock.Of <IAgentService>(x => x.AgentID == -1 && x.Name == $"{nameof(EventHandlerTests)} Mock");

            var kernel = IntegrationSetupFixture.CreateNewKernel();

            kernel.Rebind <global::Relativity.API.IHelper>().ToConstant(helper);
            kernel.Rebind <IAgentService>().ToConstant(agentService);
            return(kernel);
        }
        public void Setup()
        {
            var kernel = IntegrationSetupFixture.CreateNewKernel(true);
            var helper = TestUtilities.GetMockHelper(Config.RelativityServiceUrl, Config.RelativityRestUrl, Config.RSAPIUsername, Config.RSAPIPassword);

            kernel.Rebind <global::Relativity.API.IHelper>().ToConstant(helper.Object);
            //var mockToggleProvider = new Mock<IToggleProvider>

            var mockFactory = new Mock <IAuditLogObjectManagerFactory>();

            mockFactory.Setup(m => m.GetManager()).Returns(() => new ApiClientHelper().GetKeplerServiceReference <IExternalAuditLogObjectManager>().Value);
            kernel.Rebind <IAuditLogObjectManagerFactory>().ToConstant(mockFactory.Object);

            this.userExperienceSampleService = kernel.Get <UserExperienceSampleService>();
        }
Пример #4
0
        public async Task CreateServerBatches()
        {
            var metricDataId = 8643;

            var kernel = IntegrationSetupFixture.CreateNewKernel(true);
            var helper = TestUtilities.GetMockHelper(Config.RelativityServiceUrl, Config.RelativityRestUrl, Config.RSAPIUsername, Config.RSAPIPassword);

            kernel.Rebind <global::Relativity.API.IHelper>().ToConstant(helper.Object);

            var mockServiceFactory = new Mock <IWorkspaceAuditServiceFactory>();

            mockServiceFactory.Setup(m => m.GetAuditService(It.IsAny <int>(), It.IsAny <int>()))
            .ReturnsAsync(kernel.Get <IDataGridWorkspaceAuditService>());
            kernel.Rebind <IWorkspaceAuditServiceFactory>().ToConstant(mockServiceFactory.Object);

            var mockFactory = new Mock <IAuditLogObjectManagerFactory>();

            mockFactory.Setup(m => m.GetManager()).Returns(() => new ApiClientHelper().GetKeplerServiceReference <IExternalAuditLogObjectManager>().Value);
            kernel.Rebind <IAuditLogObjectManagerFactory>().ToConstant(mockFactory.Object);

            var actualWorkspaceService = kernel.Get <IWorkspaceService>();
            var mockWorkspaceService   = new Mock <IWorkspaceService>();

            mockWorkspaceService
            .Setup(x => x.ReadAvailableWorkspaceIdsAsync(It.IsAny <int>()))
            .Returns <int>(x => Task.FromResult <IList <int> >(
                               actualWorkspaceService.ReadAvailableWorkspaceIdsAsync(x).Result
                               .Intersect(new[] { Config.WorkSpaceId })
                               .ToList()));
            kernel.Rebind <IWorkspaceService>().ToConstant(mockWorkspaceService.Object);

            var serverBatcher = kernel.Get <AuditServerBatcher>();

            var batchIds = await serverBatcher.CreateServerBatches(metricDataId);

            Assert.That(batchIds, Is.Not.Empty);
        }