public async Task GetEventsByFiltersWithMachineId_TestAsync() { var(id, machine_id, timestamp, status) = await FakeInstanceUtils.SeedDataAsync(mongo); IDictionary <string, string> filters = new Dictionary <string, string> { { "machine_id", machine_id }, { "limit", "50" } }; var events = await getData.GetEventsByFiltersAsync(filters); Assert.InRange(events.Count(), 0, 50); foreach (var singleEvent in events) { Assert.IsAssignableFrom <IWebSocketStream>(singleEvent); Assert.IsAssignableFrom <IStreamEvent>(singleEvent.StreamEvent); Assert.IsAssignableFrom <IPayload>(singleEvent.StreamEvent.Payload); Assert.Null(singleEvent.StreamEvent.JoinRef); Assert.Null(singleEvent.StreamEvent.Ref); Assert.Equal(singleEvent.StreamEvent.Payload.MachineId, machine_id); } }
public async Task GetLastEvents_TestAsync() { var(id, machine_id, timestamp, status) = await FakeInstanceUtils.SeedDataAsync(mongo); var lastEvents = await getData.GetLastEventsAsync(20); Assert.Equal(20, lastEvents.Count()); foreach (var singleEvent in lastEvents) { Assert.IsAssignableFrom <IWebSocketStream>(singleEvent); Assert.IsAssignableFrom <IStreamEvent>(singleEvent.StreamEvent); Assert.IsAssignableFrom <IPayload>(singleEvent.StreamEvent.Payload); Assert.Null(singleEvent.StreamEvent.JoinRef); Assert.Null(singleEvent.StreamEvent.Ref); } }
public async Task GetEventsByFiltersWithEmpty_TestAsync() { var(id, machine_id, timestamp, status) = await FakeInstanceUtils.SeedDataAsync(mongo); IDictionary <string, string> filters = new Dictionary <string, string>(); var events = await getData.GetEventsByFiltersAsync(filters); Assert.Equal(31, events.Count()); foreach (var singleEvent in events) { Assert.IsAssignableFrom <IWebSocketStream>(singleEvent); Assert.IsAssignableFrom <IStreamEvent>(singleEvent.StreamEvent); Assert.IsAssignableFrom <IPayload>(singleEvent.StreamEvent.Payload); Assert.Null(singleEvent.StreamEvent.JoinRef); Assert.Null(singleEvent.StreamEvent.Ref); } }
public async Task GetEventsByFiltersWithFromTo_TestAsync() { var(id, machine_id, timestamp, status) = await FakeInstanceUtils.SeedDataAsync(mongo); IDictionary <string, string> filters = new Dictionary <string, string> { { "from", timestamp.AddMinutes(-1).ToString("yyyy-MM-ddTHH:mm:ss.fffffffK") }, { "to", DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffffffK") }, { "limit", "20" } }; var events = await getData.GetEventsByFiltersAsync(filters); Assert.InRange(events.Count(), 10, 20); foreach (var singleEvent in events) { Assert.IsAssignableFrom <IWebSocketStream>(singleEvent); Assert.IsAssignableFrom <IStreamEvent>(singleEvent.StreamEvent); Assert.IsAssignableFrom <IPayload>(singleEvent.StreamEvent.Payload); Assert.Null(singleEvent.StreamEvent.JoinRef); Assert.Null(singleEvent.StreamEvent.Ref); } }
public async Task GetEventsByFiltersWithStatus_TestAsync() { var(id, machine_id, timestamp, status) = await FakeInstanceUtils.SeedDataAsync(mongo); IDictionary <string, string> filters = new Dictionary <string, string> { { "status", $"{status},finished" }, { "limit", "50" } }; var events = await getData.GetEventsByFiltersAsync(filters); foreach (var singleEvent in events) { Assert.IsAssignableFrom <IWebSocketStream>(singleEvent); Assert.IsAssignableFrom <IStreamEvent>(singleEvent.StreamEvent); Assert.IsAssignableFrom <IPayload>(singleEvent.StreamEvent.Payload); Assert.Null(singleEvent.StreamEvent.JoinRef); Assert.Null(singleEvent.StreamEvent.Ref); Assert.Contains(singleEvent.StreamEvent.Payload.Status, new string[] { status, "finished" }); } }