Example #1
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);
        }
        public void RegisteringObservation_StateIsOverwritten()
        {
            _context.Database.EnsureDeleted();
            var service = new TimeLineService(_context);

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

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


            service.RegisterObservation(o1);
            service.RegisterObservation(o2);

            var contexts = service.SearchEvents(new string[] { }).OrderByDescending(x => x.On);

            Assert.Equal("Hello World Again", service.GetEntityState("E1", "2001/01/01 01:02")["MyNextVal"]);
        }
Example #3
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);
        }