/// <summary>
 /// Fetch all IncidentTypes
 /// </summary>
 /// <param name="dataController">Document storeage as RavenDataController</param>
 /// <returns></returns>
 public List<IncidentType> GetAllIncidentTypes(RavenDataController dataController)
 {
     return dataController.GetAll<IncidentType>();
 }
        /// <summary>
        /// Fetch distribution of IncidentTypes:  count of of each IncidentType
        /// </summary>
        /// <param name="dataController"></param>
        /// <returns>IncidentType.Type and Count as Json string</returns>
        public string GetIncidentTypeDistribution(RavenDataController dataController)
        {
            var distribution = dataController.GetAll<DistinctIncidentTypeIndex
                                                    .DistinctIncidentType>("DistinctIncidentTypeIndex");

            return JsonConvert.SerializeObject(distribution);
        }
Esempio n. 3
0
        public void CanFetchAllIncidents()
        {
            var docStore = GetDocStore();
            TruncateIncidentDocuments(docStore);

            var batchIndicents = Create15Incidents();
            var dataController = new RavenDataController(docStore);
            batchIndicents.ForEach(x => dataController.Save<Incident>(x));

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

            //  Test
            var allIncidents = dataController.GetAll<Incident>();
            Assert.AreEqual(totalCount, allIncidents.Count);
        }
Esempio n. 4
0
        public void CanQueryIndexForUnresolvedIncidents()
        {
            var docStore = GetDocStore();
            TruncateIncidentDocuments(docStore);

            var batchIncidents = Create15Incidents();

            //  Mark 5 of these as resolved
            for (int i = 0; i <= 4; i++ )
            {
                batchIncidents[i].Resolved = true;
            }

            var dataController = new RavenDataController(docStore);
            batchIncidents.ForEach(x => dataController.Save<Incident>(x));

            Raven.Client.Indexes.IndexCreation.CreateIndexes(typeof(UnresolvedIncidentIndex).Assembly, docStore);

            var unresolved = dataController.GetAll<Incident>("UnresolvedIncidentIndex");
            Assert.AreEqual(10, unresolved.Count);
        }
Esempio n. 5
0
        public void CanQueryIndexForParentIncidents()
        {
            var docStore = GetDocStore();
            TruncateIncidentDocuments(docStore);

            var batchIncidents = Create15Incidents();
            var dataController = new RavenDataController(docStore);
            batchIncidents.ForEach(x => dataController.Save<Incident>(x));

            var parentIncidents = dataController.GetAll<Incident>("ParentIncidentIndex");
            Assert.AreEqual(2, parentIncidents.Count);
        }
Esempio n. 6
0
        public void CanGetDistincIncidentTypeByIndex()
        {
            var docStore = GetDocStore();
            TruncateIncidentDocuments(docStore);

            var batchIndicents = Create15Incidents();
            var dataController = new RavenDataController(docStore);
            batchIndicents.ForEach(x => dataController.Save<Incident>(x));

            Raven.Client.Indexes.IndexCreation.CreateIndexes(typeof(DistinctIncidentTypeIndex).Assembly, docStore);

            var distinctIncidentTypes = dataController
                                        .GetAll<DistinctIncidentTypeIndex.DistinctIncidentType>
                                                ("DistinctIncidentTypeIndex");

            Assert.AreEqual(4, distinctIncidentTypes.Count);
        }