public void TestOrderingQuery_NoSorts() { List <ViewTelemetryDetail> data = new List <ViewTelemetryDetail>(); data.Add(new ViewTelemetryDetail(this.id_3) { Timestamp = new DateTime(2000, 01, 03), UserIdentifier = "CCC", EntryKey = "ZZZ" }); data.Add(new ViewTelemetryDetail(this.id_4) { Timestamp = new DateTime(2000, 01, 04), UserIdentifier = "CCC", EntryKey = "ZZZ" }); data.Add(new ViewTelemetryDetail(this.id_1) { Timestamp = new DateTime(2000, 01, 01), UserIdentifier = "AAA", EntryKey = "ZZZ" }); data.Add(new ViewTelemetryDetail(this.id_2) { Timestamp = new DateTime(2000, 01, 02), UserIdentifier = "BBB", EntryKey = "ZZZ" }); List <Tuple <string, bool> > sorts = new List <Tuple <string, bool> >(); List <ViewTelemetryDetail> ordered = ProgramsDashboardUnitOfWork.ApplyOrderingQuery(sorts, data.AsAsyncQueryable(), 0, 10).GetAwaiter().GetResult() .ToList(); Assert.AreEqual(this.id_4, ordered[0].Id); Assert.AreEqual(this.id_3, ordered[1].Id); Assert.AreEqual(this.id_2, ordered[2].Id); Assert.AreEqual(this.id_1, ordered[3].Id); }
public void TestOrderingQuery_TwoProps() { List <ViewTelemetryDetail> data = new List <ViewTelemetryDetail>(); data.Add(new ViewTelemetryDetail(this.id_1) { Timestamp = new DateTime(2000, 01, 01), UserIdentifier = "AAA", EntryKey = "ZZZ" }); data.Add(new ViewTelemetryDetail(this.id_2) { Timestamp = new DateTime(2000, 01, 02), UserIdentifier = "BBB", EntryKey = "ZZZ" }); data.Add(new ViewTelemetryDetail(this.id_3) { Timestamp = new DateTime(2000, 01, 03), UserIdentifier = "CCC", EntryKey = "ZZZ" }); data.Add(new ViewTelemetryDetail(this.id_4) { Timestamp = new DateTime(2000, 01, 04), UserIdentifier = "CCC", EntryKey = "ZZZ" }); data.Add(new ViewTelemetryDetail(this.id_5) { Timestamp = new DateTime(2000, 01, 05), UserIdentifier = "AAA", EntryKey = "XXX" }); data.Add(new ViewTelemetryDetail(this.id_6) { Timestamp = new DateTime(2000, 01, 06), UserIdentifier = "AAA", EntryKey = "YYY" }); data.Add(new ViewTelemetryDetail(this.id_7) { Timestamp = new DateTime(2000, 01, 07), UserIdentifier = "BBB", EntryKey = "YYY" }); data.Add(new ViewTelemetryDetail(this.id_8) { Timestamp = new DateTime(2000, 01, 08), UserIdentifier = "BBB", EntryKey = "XXX" }); List <Tuple <string, bool> > sorts = new List <Tuple <string, bool> >(); sorts.Add(new Tuple <string, bool>(nameof(DataTableTelemetryData.UserName), false)); sorts.Add(new Tuple <string, bool>(nameof(DataTableTelemetryData.EntryKey), false)); List <ViewTelemetryDetail> ordered = ProgramsDashboardUnitOfWork.ApplyOrderingQuery(sorts, data.AsAsyncQueryable(), 0, 10).GetAwaiter().GetResult() .ToList(); Assert.AreEqual(this.id_5, ordered[0].Id); Assert.AreEqual(this.id_6, ordered[1].Id); Assert.AreEqual(this.id_1, ordered[2].Id); Assert.AreEqual(this.id_8, ordered[3].Id); Assert.AreEqual(this.id_7, ordered[4].Id); Assert.AreEqual(this.id_2, ordered[5].Id); Assert.AreEqual(this.id_3, ordered[6].Id); Assert.AreEqual(this.id_4, ordered[7].Id); }
public void TestOrderingQuery_FailSafe() { List <ViewTelemetryDetail> data = new List <ViewTelemetryDetail>(); data.Add(new ViewTelemetryDetail(this.id_1) { Timestamp = new DateTime(2000, 01, 01), UserIdentifier = "AAA", EntryKey = "ZZZ" , AssemblyVersion = "2.0" , FileVersion = null }); data.Add(new ViewTelemetryDetail(this.id_2) { Timestamp = new DateTime(2000, 01, 02), UserIdentifier = "BBB", EntryKey = "ZZZ" , AssemblyVersion = "6.0" , FileVersion = null }); data.Add(new ViewTelemetryDetail(this.id_3) { Timestamp = new DateTime(2000, 01, 03) , UserIdentifier = "CCC", EntryKey = "ZZZ" , AssemblyVersion = "4.0" , FileVersion = null }); List <Tuple <string, bool> > sorts = new List <Tuple <string, bool> >(); sorts.Add(new Tuple <string, bool>("WrongKey", false)); List <ViewTelemetryDetail> ordered = ProgramsDashboardUnitOfWork.ApplyOrderingQuery(sorts, data.AsAsyncQueryable(), 0, 10).GetAwaiter().GetResult() .ToList(); Assert.AreEqual(this.id_3, ordered[0].Id); Assert.AreEqual(this.id_2, ordered[1].Id); Assert.AreEqual(this.id_1, ordered[2].Id); }
public void TestGetDailySumary() { var viewTelemetrySummary = new ViewTelemetrySummary(); var viewTelemetrySummary2 = new ViewTelemetrySummary(); List <ViewTelemetryDetail> data = new List <ViewTelemetryDetail>(); data.Add(new ViewTelemetryDetail(this.id_1) { Timestamp = new DateTime(2000, 01, 01), UserIdentifier = "AAA", EntryKey = "ZZZ", FileVersion = "2.0" }); data.Add(new ViewTelemetryDetail(this.id_2) { Timestamp = new DateTime(2000, 01, 02), UserIdentifier = "BBB", EntryKey = "ZZZ", FileVersion = "6.0" }); data.Add(new ViewTelemetryDetail(this.id_3) { Timestamp = new DateTime(2000, 01, 03), UserIdentifier = "CCC", EntryKey = "ZZZ", FileVersion = "4.0" }); data.Add(new ViewTelemetryDetail(this.id_3) { Timestamp = new DateTime(2000, 01, 03), UserIdentifier = "CCC", EntryKey = "ZZZ", FileVersion = "4.0" }); data.Add(new ViewTelemetryDetail(this.id_3) { Timestamp = new DateTime(2000, 01, 03), UserIdentifier = "CCC", EntryKey = "ZZZ", FileVersion = "4.0" }); data.Add(new ViewTelemetryDetail(this.id_4) { Timestamp = new DateTime(2000, 01, 04), UserIdentifier = "CCC", EntryKey = "ZZZ", FileVersion = "4.0" }); data.Add(new ViewTelemetryDetail(this.id_6) { Timestamp = new DateTime(2000, 01, 06), UserIdentifier = "AAA", EntryKey = "YYY", FileVersion = "2.0" }); data.Add(new ViewTelemetryDetail(this.id_7) { Timestamp = new DateTime(2000, 01, 07), UserIdentifier = "BBB", EntryKey = "YYY", FileVersion = "9.0" }); data.Add(new ViewTelemetryDetail(this.id_8) { Timestamp = new DateTime(2000, 01, 08), UserIdentifier = "BBB", EntryKey = "XXX", FileVersion = "1.0" }); ((List <ViewTelemetryDetail>)viewTelemetrySummary.TelemetryDetails).AddRange(data); ((List <ViewTelemetryDetail>)viewTelemetrySummary2.TelemetryDetails).Add(new ViewTelemetryDetail(this.id_3) { Timestamp = new DateTime(2000, 01, 03), UserIdentifier = "CCC", EntryKey = "ZZZ", FileVersion = "4.0" }); var ets = new EventTelemetrySummary(); ((List <EventTelemetryDetail>)ets.TelemetryDetails).Add(new EventTelemetryDetail(this.id_3) { Timestamp = new DateTime(2000, 01, 03), UserIdentifier = "CCC", EntryKey = "ZZZ", FileVersion = "4.0" }); ((List <EventTelemetryDetail>)ets.TelemetryDetails).Add(new EventTelemetryDetail(this.id_3) { Timestamp = new DateTime(2000, 01, 05), UserIdentifier = "CCC", EntryKey = "ZZZ", FileVersion = "4.0" }); var exceptions = new List <ExceptionInfo>(); exceptions.Add(new ExceptionInfo() { Timestamp = new DateTime(2000, 01, 7) }); exceptions.Add(new ExceptionInfo() { Timestamp = new DateTime(2000, 01, 7) }); exceptions.Add(new ExceptionInfo() { Timestamp = new DateTime(2000, 01, 7) }); exceptions.Add(new ExceptionInfo() { Timestamp = new DateTime(2000, 01, 7) }); var dataTable = ProgramsDashboardUnitOfWork.PrepareDailyActivityScoreTable( new DateTime(2000, 01, 03) , new DateTime(2000, 01, 07), new List <EventTelemetrySummary>() { ets } , new List <ViewTelemetrySummary>() { viewTelemetrySummary, viewTelemetrySummary2 }, exceptions); Assert.AreEqual(ProgramsDashboardUnitOfWork.ToDashboardDateString(new DateTime(2000, 01, 03)), dataTable.Rows[0]["Date"]); Assert.AreEqual(ProgramsDashboardUnitOfWork.ToDashboardDateString(new DateTime(2000, 01, 07)), dataTable.Rows[dataTable.Rows.Count - 1]["Date"]); Assert.AreEqual(5, dataTable.Rows.Count); //03.01 Assert.AreEqual(4, dataTable.Rows[0]["Views"]); Assert.AreEqual(0, dataTable.Rows[0]["Errors"]); Assert.AreEqual(1, dataTable.Rows[0]["Events"]); //04.01 Assert.AreEqual(1, dataTable.Rows[1]["Views"]); Assert.AreEqual(0, dataTable.Rows[1]["Errors"]); Assert.AreEqual(0, dataTable.Rows[1]["Events"]); //05.01 Assert.AreEqual(0, dataTable.Rows[2]["Views"]); Assert.AreEqual(0, dataTable.Rows[2]["Errors"]); Assert.AreEqual(1, dataTable.Rows[2]["Events"]); //07.01 Assert.AreEqual(1, dataTable.Rows[4]["Views"]); Assert.AreEqual(4, dataTable.Rows[4]["Errors"]); Assert.AreEqual(0, dataTable.Rows[4]["Events"]); }