Beispiel #1
0
        /// <summary>
        ///     Creates an incident and a report.
        /// </summary>
        public void CreateReportAndIncident(out int reportId, out int incidentId)
        {
            ErrorReportEntity report;

            using (var uow = CreateUnitOfWork())
            {
                report = new ErrorReportEntity(ApplicationId, Guid.NewGuid().ToString("N"), DateTime.UtcNow,
                                               new ErrorReportException(new Exception("mofo")),
                                               new List <ErrorReportContextCollection>
                {
                    new ErrorReportContextCollection("Maps", new Dictionary <string, string>())
                })
                {
                    Title = "Missing here"
                };
                report.Init(report.GenerateHashCodeIdentifier());

                uow.SaveChanges();
            }

            using (var dbContext = CreateUnitOfWork())
            {
                var incident = new IncidentBeingAnalyzed(report);
                var incRepos = new AnalyticsRepository(dbContext);
                incRepos.CreateIncident(incident);
                incidentId = incident.Id;

                report.IncidentId = incident.Id;
                incRepos.CreateReport(report);
                reportId = report.Id;

                dbContext.SaveChanges();
            }
        }
Beispiel #2
0
        /// <summary>
        ///     Creates an incident and a report.
        /// </summary>
        public void CreateReportAndIncident(out int reportId, out int incidentId)
        {
            using (var uow = CreateUnitOfWork())
            {
                CreateUserAndApplication(uow, out var accountId, out var applicationId);

                var report = new ErrorReportEntity(applicationId, Guid.NewGuid().ToString("N"), DateTime.UtcNow,
                                                   new ErrorReportException(new Exception("mofo")),
                                                   new List <ErrorReportContext>
                {
                    new ErrorReportContext("Maps", new Dictionary <string, string>())
                })
                {
                    Title = "Missing here"
                };
                report.Init(report.GenerateHashCodeIdentifier());

                var incident = new IncidentBeingAnalyzed(report);
                var incRepos = new AnalyticsRepository(new AnalysisDbContext(uow), ConfigStore);
                incRepos.CreateIncident(incident);
                incidentId = incident.Id;

                report.IncidentId = incident.Id;
                incRepos.CreateReport(report);
                reportId = report.Id;

                uow.SaveChanges();
            }
        }
Beispiel #3
0
        public void CreateUserAndApp()
        {
            using (var uow = CreateUnitOfWork())
            {
                var accountRepos = new AccountRepository(uow);
                var account      = new Account("arne", "123456")
                {
                    Email = "*****@*****.**"
                };
                accountRepos.Create(account);
                var userRepos = new UserRepository(uow);
                var user      = new User(account.Id, "arne")
                {
                    EmailAddress = "*****@*****.**"
                };
                userRepos.CreateAsync(user).GetAwaiter().GetResult();

                var appRepos = new ApplicationRepository(uow);
                var app      = new Application(account.Id, "MinApp");
                appRepos.CreateAsync(app).GetAwaiter().GetResult();
                var member = new ApplicationTeamMember(app.Id, account.Id, "Admin");
                appRepos.CreateAsync(member).GetAwaiter().GetResult();


                var report = new ErrorReportEntity(app.Id, Guid.NewGuid().ToString("N"), DateTime.UtcNow,
                                                   new ErrorReportException(new Exception("mofo")),
                                                   new List <ErrorReportContext> {
                    new ErrorReportContext("Maps", new Dictionary <string, string>())
                });
                report.Title = "Missing here";
                report.Init(report.GenerateHashCodeIdentifier());

                var incident = new ReportAnalyzer.Domain.Incidents.IncidentBeingAnalyzed(report);
                var incRepos = new AnalyticsRepository(new AnalysisDbContext(uow), ConfigStore);
                incRepos.CreateIncident(incident);
                report.IncidentId = incident.Id;
                incRepos.CreateReport(report);

                uow.SaveChanges();
            }
        }
        public void Should_load_ignored_state_into_class_correctly()
        {
            var report = new ErrorReportEntity(FirstApplicationId, Guid.NewGuid().ToString("N"), DateTime.UtcNow,
                                               new ErrorReportException(new Exception("mofo")),
                                               new List <ErrorReportContext> {
                new ErrorReportContext("Maps", new Dictionary <string, string>())
            })
            {
                Title = "Missing here"
            };

            report.Init(report.GenerateHashCodeIdentifier());

            using (var uow = new AnalysisDbContext(CreateUnitOfWork()))
            {
                var incident = new IncidentBeingAnalyzed(report);
                var incRepos = new AnalyticsRepository(uow, new TestConfigStore());
                incRepos.CreateIncident(incident);
                report.IncidentId = incident.Id;
                incRepos.CreateReport(report);
            }
        }