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")); }
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)); }
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()); }
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); }
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); }