Ejemplo n.º 1
0
        public async Task DataGrid_EndToEnd_ReadTotal()
        {
            var workspaceId = Config.WorkSpaceId;
            var auditQuery  = new AuditQuery
            {
                ActionTypes = new List <AuditActionId> {
                    AuditActionId.DocumentQuery
                },
                StartTime   = DateTime.MinValue,
                EndTime     = DateTime.UtcNow,
                WorkspaceId = workspaceId
            };

            // However we grab this for testing...
            var apiClientHelper       = new ApiClientHelper();
            var auditLogObjectManager = apiClientHelper.GetKeplerServiceReference <IExternalAuditLogObjectManager>();
            //using (var auditLogObjectManager = TestUtilities.GetServicesManager().CreateProxy<IExternalAuditLogObjectManager>(ExecutionIdentity.System))

            // Mock it up for the implementation
            var mockFactory = new Mock <IAuditLogObjectManagerFactory>();

            mockFactory.Setup(m => m.GetManager()).Returns(() => auditLogObjectManager.Value);
            var dataGridWorkspaceAuditService = DataGridEndToEnd.SetUpWorkspaceAuditService(mockFactory.Object);

            var result =
                await
                dataGridWorkspaceAuditService.ReadTotalAuditsForHourAsync(workspaceId, auditQuery.StartTime, auditQuery.EndTime,
                                                                          auditQuery.ActionTypes);

            Assert.Pass($"Test Passed - ResultCount {result}");
        }
Ejemplo n.º 2
0
        public async Task DataGrid_EndToEnd_ReadAudits()
        {
            var workspaceId = Config.WorkSpaceId;
            var auditQuery  = new AuditQuery
            {
                ActionTypes = new List <AuditActionId> {
                    AuditActionId.DocumentQuery
                },
                StartTime   = DateTime.MinValue,
                EndTime     = DateTime.UtcNow,
                WorkspaceId = workspaceId
            };

            var queryBatch = new AuditQueryBatch
            {
                Query = auditQuery,
                Size  = 50,
                Start = 0
            };

            // However we grab this for testing...
            var apiClientHelper       = new ApiClientHelper();
            var auditLogObjectManager = apiClientHelper.GetKeplerServiceReference <IExternalAuditLogObjectManager>();
            // Mock it up for the implementation
            var mockFactory = new Mock <IAuditLogObjectManagerFactory>();

            mockFactory.Setup(m => m.GetManager()).Returns(() => auditLogObjectManager.Value);
            var dataGridWorkspaceAuditService = DataGridEndToEnd.SetUpWorkspaceAuditService(mockFactory.Object);

            var result = await dataGridWorkspaceAuditService.ReadAuditsAsync(workspaceId, auditQuery.StartTime,
                                                                             auditQuery.EndTime,
                                                                             auditQuery.ActionTypes, queryBatch.Size, queryBatch.Start);

            var resultMessages =
                result.Select(
                    r =>
                    $"AuditId: {r.AuditID}, UserId {r.UserID}, Action: {r.Action}, ArtifactID: {r.ArtifactID}, ExecutionTime: {r.ExecutionTime}, WorkspaceId: {r.WorkspaceId}, TimeStamp: {r.TimeStamp}, Details: {r.Details}");
            var finalMessage = string.Join("||", resultMessages);

            Assert.Pass($"Test Passed - ResultCount {result.Count} -- {finalMessage}");
        }