コード例 #1
0
        public void SyncErrorStackTags()
        {
            const string Tag1           = "Tag One";
            const string Tag2           = "Tag Two";
            const string Tag2_Lowercase = "tag two";

            Error error = ErrorData.GenerateError(id: TestConstants.ErrorId, projectId: TestConstants.ProjectId, organizationId: TestConstants.OrganizationId, nestingLevel: 5, minimiumNestingLevel: 1);

            error.Tags = new TagSet {
                Tag1
            };

            var pipeline = IoC.GetInstance <ErrorPipeline>();

            Assert.DoesNotThrow(() => pipeline.Run(error));

            error = Repository.GetById(error.Id);
            Assert.NotNull(error);
            Assert.NotNull(error.ErrorStackId);

            var stack = _errorStackRepository.GetById(error.ErrorStackId);

            Assert.Equal(new TagSet {
                Tag1
            }, stack.Tags);

            error      = ErrorData.GenerateError(errorStackId: error.ErrorStackId, projectId: TestConstants.ProjectId, organizationId: TestConstants.OrganizationId, nestingLevel: 5, minimiumNestingLevel: 1);
            error.Tags = new TagSet {
                Tag2
            };

            Assert.DoesNotThrow(() => pipeline.Run(error));
            stack = _errorStackRepository.GetById(error.ErrorStackId);
            Assert.Equal(new TagSet {
                Tag1, Tag2
            }, stack.Tags);

            error      = ErrorData.GenerateError(errorStackId: error.ErrorStackId, projectId: TestConstants.ProjectId, organizationId: TestConstants.OrganizationId, nestingLevel: 5, minimiumNestingLevel: 1);
            error.Tags = new TagSet {
                Tag2_Lowercase
            };

            Assert.DoesNotThrow(() => pipeline.Run(error));
            stack = _errorStackRepository.GetById(error.ErrorStackId);
            Assert.Equal(new TagSet {
                Tag1, Tag2
            }, stack.Tags);
        }
コード例 #2
0
        protected override void CreateData()
        {
            var occurrenceDateStart = new DateTimeOffset(DateTime.Now.AddMinutes(-30));
            var occurrenceDateMid   = new DateTimeOffset(DateTime.Now);
            var occurrenceDateEnd   = new DateTimeOffset(DateTime.Now.AddMinutes(30));

            _errorStackRepository.Add(ErrorStackData.GenerateErrorStack(id: TestConstants.ErrorStackId, organizationId: TestConstants.OrganizationId, projectId: TestConstants.ProjectId));

            _ids.Add(Tuple.Create(ObjectId.GenerateNewId().ToString(), occurrenceDateStart));
            Repository.Add(ErrorData.GenerateError(id: _ids.Last().Item1, projectId: TestConstants.ProjectId, organizationId: TestConstants.OrganizationId, errorStackId: TestConstants.ErrorStackId, occurrenceDate: _ids.Last().Item2, nestingLevel: 5, minimiumNestingLevel: 1));

            _ids.Add(Tuple.Create(ObjectId.GenerateNewId().ToString(), occurrenceDateEnd));
            Repository.Add(ErrorData.GenerateError(id: _ids.Last().Item1, projectId: TestConstants.ProjectId, organizationId: TestConstants.OrganizationId, errorStackId: TestConstants.ErrorStackId, occurrenceDate: _ids.Last().Item2, nestingLevel: 5, minimiumNestingLevel: 1));

            _ids.Add(Tuple.Create(ObjectId.GenerateNewId().ToString(), new DateTimeOffset(DateTime.Now.AddMinutes(-10))));
            Repository.Add(ErrorData.GenerateError(id: _ids.Last().Item1, projectId: TestConstants.ProjectId, organizationId: TestConstants.OrganizationId, errorStackId: TestConstants.ErrorStackId, occurrenceDate: _ids.Last().Item2, nestingLevel: 5, minimiumNestingLevel: 1));

            _ids.Add(Tuple.Create(ObjectId.GenerateNewId().ToString(), new DateTimeOffset(DateTime.Now.AddMinutes(-20))));
            Repository.Add(ErrorData.GenerateError(id: _ids.Last().Item1, projectId: TestConstants.ProjectId, organizationId: TestConstants.OrganizationId, errorStackId: TestConstants.ErrorStackId, occurrenceDate: _ids.Last().Item2, nestingLevel: 5, minimiumNestingLevel: 1));

            _ids.Add(Tuple.Create(ObjectId.GenerateNewId().ToString(), occurrenceDateMid));
            Repository.Add(ErrorData.GenerateError(id: _ids.Last().Item1, projectId: TestConstants.ProjectId, organizationId: TestConstants.OrganizationId, errorStackId: TestConstants.ErrorStackId, occurrenceDate: _ids.Last().Item2, nestingLevel: 5, minimiumNestingLevel: 1));

            _ids.Add(Tuple.Create(ObjectId.GenerateNewId().ToString(), occurrenceDateMid));
            Repository.Add(ErrorData.GenerateError(id: _ids.Last().Item1, projectId: TestConstants.ProjectId, organizationId: TestConstants.OrganizationId, errorStackId: TestConstants.ErrorStackId, occurrenceDate: _ids.Last().Item2, nestingLevel: 5, minimiumNestingLevel: 1));

            _ids.Add(Tuple.Create(ObjectId.GenerateNewId().ToString(), occurrenceDateMid));
            Repository.Add(ErrorData.GenerateError(id: _ids.Last().Item1, projectId: TestConstants.ProjectId, organizationId: TestConstants.OrganizationId, errorStackId: TestConstants.ErrorStackId, occurrenceDate: _ids.Last().Item2, nestingLevel: 5, minimiumNestingLevel: 1));

            _ids.Add(Tuple.Create(ObjectId.GenerateNewId().ToString(), new DateTimeOffset(DateTime.Now.AddMinutes(20))));
            Repository.Add(ErrorData.GenerateError(id: _ids.Last().Item1, projectId: TestConstants.ProjectId, organizationId: TestConstants.OrganizationId, errorStackId: TestConstants.ErrorStackId, occurrenceDate: _ids.Last().Item2, nestingLevel: 5, minimiumNestingLevel: 1));

            _ids.Add(Tuple.Create(ObjectId.GenerateNewId().ToString(), new DateTimeOffset(DateTime.Now.AddMinutes(10))));
            Repository.Add(ErrorData.GenerateError(id: _ids.Last().Item1, projectId: TestConstants.ProjectId, organizationId: TestConstants.OrganizationId, errorStackId: TestConstants.ErrorStackId, occurrenceDate: _ids.Last().Item2, nestingLevel: 5, minimiumNestingLevel: 1));

            _ids.Add(Tuple.Create(ObjectId.GenerateNewId().ToString(), new DateTimeOffset(DateTime.Now.AddSeconds(1))));
            Repository.Add(ErrorData.GenerateError(id: _ids.Last().Item1, projectId: TestConstants.ProjectId, organizationId: TestConstants.OrganizationId, errorStackId: TestConstants.ErrorStackId, occurrenceDate: _ids.Last().Item2, nestingLevel: 5, minimiumNestingLevel: 1));

            _ids.Add(Tuple.Create(ObjectId.GenerateNewId().ToString(), occurrenceDateEnd));
            Repository.Add(ErrorData.GenerateError(id: _ids.Last().Item1, projectId: TestConstants.ProjectId, organizationId: TestConstants.OrganizationId, errorStackId: TestConstants.ErrorStackId, occurrenceDate: _ids.Last().Item2, nestingLevel: 5, minimiumNestingLevel: 1));

            _ids.Add(Tuple.Create(ObjectId.GenerateNewId().ToString(), occurrenceDateStart));
            Repository.Add(ErrorData.GenerateError(id: _ids.Last().Item1, projectId: TestConstants.ProjectId, organizationId: TestConstants.OrganizationId, errorStackId: TestConstants.ErrorStackId, occurrenceDate: _ids.Last().Item2, nestingLevel: 5, minimiumNestingLevel: 1));
        }
コード例 #3
0
        public void CreateUpdateRemove()
        {
            Assert.Equal(0, Repository.Count());

            Error entity = ErrorData.GenerateError();

            Assert.Null(entity.Id);

            // Insert a document
            var error = Repository.Add(entity);

            Assert.False(String.IsNullOrEmpty(error.Id));
            Assert.False(String.IsNullOrEmpty(entity.Id));
            Assert.Equal(error.Id, entity.Id);

            string id = error.Id;

            Assert.False(String.IsNullOrEmpty(id));

            // Find an existing document
            error = Repository.FirstOrDefault(e => e.Id == id);
            Assert.NotNull(error);
            Assert.Equal(id, error.Id);

            // Save a changed document
            error.UserDescription = "Unit Test 2";
            Repository.Update(error);

            // Update an existing document
            var errors = Repository.Where(e => e.Id == id);

            foreach (var er in errors)
            {
                er.UserDescription = "Unit Test";
            }

            Repository.Update(errors);

            Repository.Delete(id);
        }
コード例 #4
0
        public void ProcessErrorTest()
        {
            Error error = ErrorData.GenerateError(id: TestConstants.ErrorId, projectId: TestConstants.ProjectId, organizationId: TestConstants.OrganizationId, nestingLevel: 5, minimiumNestingLevel: 1);

            var organization = _organizationRepository.GetById(TestConstants.OrganizationId);

            Assert.Equal(1, organization.ProjectCount);
            Assert.Equal(0, organization.StackCount);
            Assert.Equal(0, organization.ErrorCount);
            Assert.Equal(0, organization.TotalErrorCount);

            var project = _projectRepository.GetById(TestConstants.ProjectId);

            Assert.Equal(0, project.StackCount);
            Assert.Equal(0, project.ErrorCount);
            Assert.Equal(0, project.TotalErrorCount);

            var       pipeline  = IoC.GetInstance <ErrorPipeline>();
            Exception exception = Record.Exception(() => pipeline.Run(error));

            Assert.Null(exception);

            organization = _organizationRepository.GetById(TestConstants.OrganizationId);
            Assert.Equal(1, organization.StackCount);
            Assert.Equal(1, organization.ErrorCount);
            Assert.Equal(1, organization.TotalErrorCount);

            project = _projectRepository.GetById(TestConstants.ProjectId);
            Assert.Equal(1, project.StackCount);
            Assert.Equal(1, project.ErrorCount);
            Assert.Equal(1, project.TotalErrorCount);

            exception = Record.Exception(() => pipeline.Run(error));
            Assert.Null(exception);
            organization = _organizationRepository.GetById(TestConstants.OrganizationId);
            Assert.Equal(1, organization.StackCount);
            Assert.Equal(1, organization.ErrorCount);
            Assert.Equal(1, organization.TotalErrorCount);

            project = _projectRepository.GetById(TestConstants.ProjectId);
            Assert.Equal(1, project.StackCount);
            Assert.Equal(1, project.ErrorCount);
            Assert.Equal(1, project.TotalErrorCount);

            error.Id  = TestConstants.ErrorId2;
            exception = Record.Exception(() => pipeline.Run(error));
            Assert.Null(exception);

            organization = _organizationRepository.GetById(TestConstants.OrganizationId);
            Assert.Equal(1, organization.StackCount);
            Assert.Equal(2, organization.ErrorCount);
            Assert.Equal(2, organization.TotalErrorCount);

            project = _projectRepository.GetById(TestConstants.ProjectId);
            Assert.Equal(1, project.StackCount);
            Assert.Equal(2, project.ErrorCount);
            Assert.Equal(2, project.TotalErrorCount);

            exception = Record.Exception(() => pipeline.Run(ErrorData.GenerateSampleError(TestConstants.ErrorId8)));
            Assert.Null(exception);

            organization = _organizationRepository.GetById(TestConstants.OrganizationId);
            Assert.Equal(2, organization.StackCount);
            Assert.Equal(3, organization.ErrorCount);
            Assert.Equal(3, organization.TotalErrorCount);

            project = _projectRepository.GetById(TestConstants.ProjectId);
            Assert.Equal(2, project.StackCount);
            Assert.Equal(3, project.ErrorCount);
            Assert.Equal(3, project.TotalErrorCount);

            Repository.RemoveAllByErrorStackIdAsync(error.ErrorStackId).Wait();
            organization = _organizationRepository.GetById(TestConstants.OrganizationId);
            Assert.Equal(2, organization.StackCount);
            Assert.Equal(1, organization.ErrorCount);
            Assert.Equal(3, organization.TotalErrorCount);

            project = _projectRepository.GetById(TestConstants.ProjectId);
            Assert.Equal(2, project.StackCount);
            Assert.Equal(1, project.ErrorCount);
            Assert.Equal(3, project.TotalErrorCount);
        }