Exemple #1
0
        public void Entity_State_Tracked()
        {
            var e1 = new NewEvent()
            {
                On       = "2001/01/01 01:01",
                Type     = "MyEventType",
                Entities = new [] { "E1" }
            };

            var o1 = new Observation()
            {
                On          = "2001/01/01 01:01",
                Entity      = "E1",
                Expressions = new[] { "State.MyVal=Hello World" }
            };

            var e2 = new NewEvent()
            {
                On       = "2001/01/01 01:02",
                Type     = "MyEventType",
                Entities = new[] { "E1" }
            };

            var o2 = new Observation()
            {
                On          = "2001/01/01 01:02",
                Entity      = "E1",
                Expressions = new[] { "State.MyVal=Hello World Again" }
            };



            _service.RegisterObservation(o1);
            _service.RegisterEvent(e1);
            _service.RegisterObservation(o2);
            _service.RegisterEvent(e2);

            var state1 = _service.GetEntityState("E1", "2001 /01/01 01:01");
            var state2 = _service.GetEntityState("E1", "2001/01/01 01:02");
            var state3 = _service.GetEntityState("BADID", "2001/01/01 01:02");

            Assert.Equal("Hello World", state1["MyVal"]);
            Assert.Equal("Hello World Again", state2["MyVal"]);
            Assert.False(state3.ContainsKey("MyVal"));
        }
Exemple #2
0
        public void RegisteringEvent_Must_Be_RegisteredEntity()
        {
            _context.Database.EnsureDeleted();
            var service = new TimeLineService(_context);

            var e = new NewEvent()
            {
                On   = "2001/01/01",
                Type = "MyEventType"
            };

            Assert.Throws <Exception>(() => service.RegisterEvent(e));
        }
Exemple #3
0
        public void RegisteringObservation_IsReturned_In_EventType_List()
        {
            _context.Database.EnsureDeleted();
            var service = new TimeLineService(_context);

            var e1 = new NewEvent()
            {
                On       = "2001/01/01 01:01",
                Type     = "MyEventType",
                Entities = new [] { "E1" }
            };

            service.RegisterEvent(e1);

            Assert.Equal("MyEventType", service.SearchEventTypes("My").First());
        }
Exemple #4
0
        public void RegisteringEvent_CanBeRetrieved()
        {
            _context.Database.EnsureDeleted();
            var service = new TimeLineService(_context);

            var e = new NewEvent()
            {
                On       = "2001/01/01",
                Type     = "MyEventType",
                Entities = new [] { "E1" }
            };


            service.RegisterEvent(e);

            var contexts = service.SearchEvents(new string[] {});

            Assert.Single(contexts);
        }
        public void ClusterFilter_LessThanOrEqual_Within_Filter()
        {
            _context.Database.EnsureDeleted();

            var e1 = new NewEvent()
            {
                On       = "2001/01/01 01:01",
                Type     = "MyEventType1",
                Entities = new[] { "E1" }
            };

            var e2 = new NewEvent()
            {
                On       = "2001/01/01 01:06",
                Type     = "MyEventType1",
                Entities = new[] { "E1" }
            };

            _service.RegisterEvent(e1);
            _service.RegisterEvent(e2);

            var match = _service.ClusterEvents(
                new string[] { "On > 2001/01/01 01:00" },
                new string[] { "Within <= 0.0:5:0" });


            Assert.Single(match);
            Assert.Equal(new DateTime(2001, 1, 1, 1, 1, 0).ToString("yyyy-MM-ddTHH\\:mm\\:ss.fffffffzzz"), match.First().Start);
            Assert.Equal(new DateTime(2001, 1, 1, 1, 6, 0).ToString("yyyy-MM-ddTHH\\:mm\\:ss.fffffffzzz"), match.First().End);
        }
Exemple #6
0
        public void FilterEvent_BasicStateMatch()
        {
            _context.Database.EnsureDeleted();

            var e1 = new NewEvent()
            {
                On       = "2001/01/01 01:01",
                Type     = "MyEventType",
                Entities = new string[] { "E1" }
            };

            var o1 = new Observation()
            {
                On          = "2001/01/01 01:01",
                Type        = "MyObservationType",
                Entity      = "E1",
                Expressions = new string[] { "State.MyVal=Hello World" }
            };

            _service.RegisterObservation(o1);
            _service.RegisterEvent(e1);


            var match    = _service.SearchEvents(new string[] { "State.MyVal=Hello World" });
            var nonMatch = _service.SearchEvents(new string[] { "State.MyVal=Not The One!" });

            Assert.Single(match);
            Assert.Empty(nonMatch);
        }