Exemplo n.º 1
0
        public void LogError(string jsonError)
        {
            Enforce.That(string.IsNullOrEmpty(jsonError) == false,
                                "ErrorLogging.LogError - jsonError can not be null");

            var errorLoggingController = new ErrorLoggingController();
            errorLoggingController.LogIncident(jsonError, Application["RavenDataController"] as RavenDataController);
        }
Exemplo n.º 2
0
        void Application_Error(object sender, EventArgs e)
        {
            //  A server side exception was not handled.  Create an incident
            var errorController = new ErrorLoggingController();

            var incident = new Incident();
            incident.OriginalErrorMessage = Server.GetLastError().Message;
            errorController.LogIncident(incident, Application["RavenDataController"] as RavenDataController);
        }
Exemplo n.º 3
0
        public void CanDeleteIncident()
        {
            //  Prep
            var docStore = GetDocStore();
            TruncateIncidentDocuments(docStore);

            var repository = new RavenDataController(docStore);
            var incident = CreateTransitionError();
            incident.PageName = "FindAnDeleteMe";

            var errorLoggingController = new ErrorLoggingController();
            string id = errorLoggingController
                        .LogIncident(JsonConvert.SerializeObject(incident), repository);

            int postLogCount = 0;

            using (var session = docStore.OpenSession())
            {
                postLogCount = session.Query<Incident>()
                                        .Customize(x => x.WaitForNonStaleResults())
                                        .Count();
            }

            //  Test
            errorLoggingController.DeleteIncident(id, repository);

            int postDeleteCount = 0;
            using (var session = docStore.OpenSession())
            {
                postDeleteCount = session.Query<Incident>()
                                        .Customize(x => x.WaitForNonStaleResults())
                                        .Count();
            }

            Assert.AreEqual(postLogCount, postDeleteCount + 1);
        }
Exemplo n.º 4
0
        public void CanFindParentIncident()
        {
            //  Prep
            var docStore = GetDocStore();
            TruncateIncidentDocuments(docStore);

            var parentIncident = CreateTransitionError();
            parentIncident.IncidentType = new IncidentType("ParentTypeError", new DateTime(2012, 1, 31),
                                                "The Parent Type", "Truncate database");

            var repository = new RavenDataController(docStore);
            repository.Save<Incident>(parentIncident);

            //  2 more incidents for our searching
            var incident2 = CreateTransitionError();
            incident2.PageName = "Incident 2";
            repository.Save<Incident>(incident2);

            var incident3 = CreateTransitionError();
            incident3.PageName = "Incident 3";
            repository.Save<Incident>(incident3);

            //  Test
            var errorLoggingController = new ErrorLoggingController();
            var foundParent = errorLoggingController.FindParent(parentIncident.HashedTitle, repository);

            Console.WriteLine(parentIncident.Id);
            Assert.AreEqual(parentIncident.IncidentType.Type, foundParent.IncidentType.Type);
        }
Exemplo n.º 5
0
        public void CanLogIncidentAndAssociateToParent()
        {
            //  Prep
            var docStore = GetDocStore();
            TruncateIncidentDocuments(docStore);

            //  Parent
            var parentIncident = CreateTransitionError();
            parentIncident.IncidentType = new IncidentType("ParentTypeError", new DateTime(2012, 1, 31),
                                                "The Parent Type", "Truncate database");

            var repository = new RavenDataController(docStore);
            repository.Save<Incident>(parentIncident);

            //  2 more incidents for our searching
            var incident2 = CreateTransitionError();
            incident2.PageName = "Incident 2";
            repository.Save<Incident>(incident2);

            var incident3 = CreateTransitionError();
            incident3.PageName = "Incident 3";
            repository.Save<Incident>(incident3);

            //The child incident
            var childincident = CreateTransitionError();
            var errorController = new ErrorLoggingController();
            string childId = errorController.LogIncident(JsonConvert.SerializeObject(childincident), repository);

            var savedChild = repository.Get<Incident>(childId);

            Console.WriteLine("Child Parent Id " + savedChild.ParentIncidentId + " : Parent Id " + parentIncident.Id);
            Assert.AreEqual(parentIncident.Id, savedChild.ParentIncidentId);
        }
Exemplo n.º 6
0
        public void CanLogIncident()
        {
            //  Prep
            var docStore = GetDocStore();
            TruncateIncidentDocuments(docStore);
            int postUpdateCount = 0;

            var newIncident = CreateTransitionError();
            var repository = new RavenDataController(docStore);

            var errorLoggingController = new ErrorLoggingController();
            string json = JsonConvert.SerializeObject(newIncident);
            errorLoggingController.LogIncident(json, repository);

            using (var session = docStore.OpenSession())
            {
                postUpdateCount = session.Query<Incident>()
                                            .Customize(x => x.WaitForNonStaleResults())
                                            .Count();
            }

            Assert.AreEqual(1, postUpdateCount);
        }