public void NullTest() { var autostat = new AutoStat <TestRecord>(); autostat.GetStats().ToTextFormat(); autostat.GetStats().ToTextTableFormat(20); }
public void CustomStatTest() { var config = new TestConfiguration(SelectionMode.All, Configuration.DefaultStatCollectors.Append("TestStatCollector")); var autostat = new AutoStat <TestRecord>(config); autostat.GetStats().ToTextFormat(); }
public void CustomStatSelectionTest() { var config = new Configuration(SelectionMode.All, "CountStatCollector"); var autostat = new AutoStat <TestRecord>(config); autostat.Collect(new TestRecord()); var stats = autostat.GetStats().ToList(); Assert.True(stats.Where(stat => stat.Name != "Count").Any() == false, "More than the specified stat has been collected."); }
public void CustomMemberTest() { var config = new Configuration(SelectionMode.Attribute); var autostat = new AutoStat <TestRecord>(config); autostat.Collect(new TestRecord()); var stats = autostat.GetStats().ToList(); Assert.True(stats.Where(stat => stat.MemberName != "Name").Any() == false, "More than the specified member had statistics."); }
public void ResetTest() { var autostat = new AutoStat <TestRecord>(); int count = 100; void CollectSomeRecords() { for (int i = 0; i < count; i++) { TestRecord record = new TestRecord() { Name = "John" + i.ToString().PadLeft(6, '0'), Weight = count - (i / (count - i)), ID = i, TransactionID = Guid.NewGuid(), NetWorth = 5000, SeenDate = DateTime.Now, OtherDate = DateTimeOffset.Now, PocketChange = new decimal(0.01) * new decimal(i), TimeSpent = TimeSpan.FromMinutes(60), CarColor = Color.Red, SomeObject = new object(), SometimesNullObject = i % 2 == 0 ? null : new object() }; autostat.Collect(record); } } CollectSomeRecords(); Assert.True(autostat.Count == 100); autostat.Reset(); CollectSomeRecords(); var stats2 = autostat.GetStats(); Assert.True(autostat.Count == 100); Assert.True((stats2.Where(stat => stat.MemberName == "Name" && stat.Name == "Count").First() as CountStat).Count == count); }
public void StatsTest() { var autostat = new AutoStat <TestRecord>(); int count = 1_000; for (int i = 0; i < count; i++) { TestRecord record = new TestRecord() { Name = "John" + i.ToString().PadLeft(6, '0'), Weight = count - (i / (count - i)), ID = i, TransactionID = Guid.NewGuid(), NetWorth = 5000, SeenDate = DateTime.Now, OtherDate = DateTimeOffset.Now, PocketChange = new decimal(0.01) * new decimal(i), TimeSpent = TimeSpan.FromMinutes(60), CarColor = Color.Red, SomeObject = new object(), SometimesNullObject = i % 2 == 0 ? null : new object() }; autostat.Collect(record); } var recordStats = autostat.GetStats(); Assert.True((recordStats.Where(stat => stat.MemberName == "Name" && stat.Name == "Count").First() as CountStat).Count == 1_000); Assert.True((recordStats.Where(stat => stat.MemberName == "SometimesNullObject" && stat.Name == "Non-Default Count").First() as NonDefaultCountStat).CountNonDefault == 500); Assert.True(Math.Abs((recordStats.Where(stat => stat.MemberName == "Name" && stat.Name.Contains("Distinct")).First() as DistinctStat).Count - 1_000) < 100); Assert.True((recordStats.Where(stat => stat.MemberName == "Weight" && stat.Name == "Max").First() as MaxStat <int>).Max == 1_000); Assert.True((recordStats.Where(stat => stat.MemberName == "Weight" && stat.Name == "Min").First() as MinStat <int>).Min == 0); Assert.True(Math.Abs((recordStats.Where(stat => stat.MemberName == "ID" && stat.Name == "Mean").First() as MeanStat <long>).Mean - 500) <= 1); Assert.True(Math.Abs((recordStats.Where(stat => stat.MemberName == "ID" && stat.Name == "Standard Deviation").First() as StandardDeviationStat <long>).Value - 288) <= 1); //Assert.True((recordStats.Where(stat => stat.MemberName == "ID" && stat.Name == "Sum").First() as SumStat<long>).Sum == 499500); Assert.True((recordStats.Where(stat => stat.MemberName == "Weight" && stat.Name == "~ 1th Percentile").First() as PercentileStat <int>).Value == 901); Assert.True((recordStats.Where(stat => stat.MemberName == "Weight" && stat.Name.Contains("1st Most Frequent")).First() as MostFrequentStat <int>).Value == 1000); }
public void NUllTest() { var autostat1 = new AutoStat <TestRecord>(keyName: "id"); int count = 1_000; for (int i = 0; i < count; i++) { TestRecord record = new TestRecord() { Name = "John" + i.ToString().PadLeft(6, '0'), Weight = count - (i / (count - i)), ID = i, TransactionID = Guid.NewGuid(), NetWorth = 5000, SeenDate = DateTime.Now, OtherDate = DateTimeOffset.Now, PocketChange = new decimal(0.01) * new decimal(i), TimeSpent = TimeSpan.FromMinutes(60), CarColor = Color.Red, SomeObject = new object(), SometimesNullObject = i % 2 == 0 ? null : new object() }; autostat1.Collect(record); } var autostat2 = new AutoStat <TestRecord>(keyName: "id"); var temp = autostat2.GetStats(); var autostat3 = new AutoStat <TestRecord>(keyName: "id"); var stats1 = autostat1.GetStatsComparedTo(autostat2); var stats2 = autostat2.GetStatsComparedTo(autostat1); var stats3 = autostat2.GetStatsComparedTo(autostat3); var stats4 = autostat1.GetStatsComparedTo(autostat1); }
static void Main(string[] args) { //var config = new TestConfiguration(SelectionMode.Attribute, Configuration.DefaultStatCollectors.Append("TestStatCollector")); var config = new TestConfiguration(SelectionMode.All, Configuration.DefaultStatCollectors.Append("TestStatCollector")); //var autoStat1 = new AutoStat<Host>(config); var autoStat1 = new AutoStat <Host>(keyName: "id"); //var autoStat2 = new AutoStat<Host>(config); var autoStat2 = new AutoStat <Host>(keyName: "id"); Random random = new Random(); int recordCount = 1_000_000; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); for (int i = 0; i < recordCount; i++) { Host record = new Host() { Name = "Wyatt" + i.ToString().PadLeft(6, '0'), SerialNumber = i, Id = i, Uptime = TimeSpan.FromMinutes(i), PokerMoney = new decimal(0.01) * new decimal(i), DeathCount = recordCount - (i / (recordCount - i)), Awareness = Awareness.NotAlive, Escaped = random.Next(0, 2) == 1 }; autoStat1.Collect(record); } Console.WriteLine(stopwatch.Elapsed); //return; var recordStats1 = autoStat1.GetStats(); Console.Write(recordStats1.ToTextFormat()); //recordStats = recordStats.Where(stat => stat.MemberName == "SerialNumber").ToRecordStats(); Console.Write(recordStats1.ToTextTableFormat(Console.WindowWidth)); //recordStats1.OpenCsvInPowershell("stats.csv"); for (int i = 0; i < recordCount; i++) { Host record = new Host() { Name = "Wyatt" + i.ToString().PadLeft(6, '0'), SerialNumber = i + recordCount, Id = i, Uptime = TimeSpan.FromMinutes(i), PokerMoney = new decimal(0.02) * new decimal(i), DeathCount = recordCount - (i / (recordCount - i)), Awareness = random.Next(0, 2) == 1 ? Awareness.NotAlive : Awareness.Alive, Escaped = true }; autoStat2.Collect(record); } var recordStats2 = autoStat2.GetStats(); Console.Write(recordStats2.ToTextFormat()); Console.Write(recordStats2.ToTextTableFormat(Console.WindowWidth)); //recordStats1.OpenCsvInPowershell("stats.csv"); var recordStats3 = autoStat1.GetStatsComparedTo(autoStat2) .HighlightWhen(stat => stat.DiffPct >= .30); Console.Write(recordStats3.ToTextFormat()); Console.Write(recordStats3.ToTextTableFormat(Console.WindowWidth)); //recordStats1.OpenCsvInPowershell("stats.csv"); Console.ReadKey(); }