示例#1
0
 public void Client()
 {
     Race race = new Race(new[] {"asdfasdf"}) {TotalFilesExpected = 5};
     Output output = new Output(race);
     Assert.AreEqual("=[   0/5   ]=", output.Format("=[   0/{5,-3:B3} ]="));
     Assert.AreEqual("=[   0/asd ]=", output.Format("=[   0/asd ]="));
     RaceStats raceStats = new RaceStats();
     const ulong bytes = 123456789;
     raceStats
         .AddFileName("a.txt")
         .AddCrc32("aabbccdd")
         .AddFileUploaded(true)
         .AddFileSpeed(100)
         .AddFileSize(bytes)
         .AddUserName("user1")
         .AddGroupName("group1");
     race.AddRaceStats(raceStats);
     Assert.AreEqual("]-[Complete 123456789MB - 1/5F]-[", output.Format("]-[Complete {7}MB - {6}/{5}F]-["));
     Assert.AreEqual("]-[Complete 117MB - 1/5F]-[", output.Format("]-[Complete {8}MB - {6}/{5}F]-["));
     Assert.AreEqual("|  1.           user1/group1           117MB   100kBit/s   1F |",
                     output.FormatUserStats(1,
                                            race.GetUserStats() [0],
                                            "| {0,2:B2}. {2,15:B15}/{3,-15:B15} {8,6:B6} {6,5:B5}kBit/s {7,3:B3}F |"));
     Assert.AreEqual("|  1. group1           117MB   100kBit/s   1F |",
                     output.FormatGroupStats(1,
                                             race.GetGroupStats() [0],
                                             "| {0,2:B2}. {3,-15:B15} {7,6:B6} {5,5:B5}kBit/s {6,3:B3}F |"));
     Assert.AreEqual("###--------------", output.Format("{14}"), "ProgressBar");
     Assert.AreEqual("117MB", bytes.FormatSize(), "FormatBytesUploaded");
 }
示例#2
0
 public void AddRaceStats()
 {
     Race race = new Race (ArgsRarPart1);
     RaceStats raceStats = new RaceStats ();
     raceStats
         .AddFileName ("a.txt")
         .AddCrc32 ("aabbccdd")
         .AddFileUploaded (true)
         .AddFileSpeed (1000)
         .AddFileSize (1000000)
         .AddUserName ("user1")
         .AddGroupName ("group1");
     race.AddRaceStats (raceStats);
     Assert.AreEqual(1, race.TotalFilesUploaded, "TotalFilesUploaded");
     Assert.AreEqual((UInt64)1000000, race.TotalBytesUploaded, "TotalBytesUploaded");
     // Ignored because file was not uploaded
     raceStats = new RaceStats();
     raceStats
         .AddFileName("d.txt")
         .AddCrc32("33bbccdd")
         .AddFileUploaded(false)
         .AddFileSpeed(400)
         .AddFileSize(4000000)
         .AddUserName("user4")
         .AddGroupName("group3");
     race.AddRaceStats(raceStats);
     Assert.AreEqual(1, race.TotalFilesUploaded, "TotalFilesUploaded");
     Assert.AreEqual((UInt64)1000000, race.TotalBytesUploaded, "TotalBytesUploaded");
     raceStats = new RaceStats();
     raceStats
         .AddFileName ("c.txt")
         .AddCrc32 ("22bbccdd")
         .AddFileUploaded (true)
         .AddFileSpeed (300)
         .AddFileSize (3000000)
         .AddUserName ("user3")
         .AddGroupName ("group1");
     race.AddRaceStats (raceStats);
     Assert.AreEqual(2, race.TotalFilesUploaded, "TotalFilesUploaded");
     Assert.AreEqual((UInt64)4000000, race.TotalBytesUploaded, "TotalBytesUploaded");
     raceStats = new RaceStats();
     raceStats
         .AddFileName("b.txt")
         .AddCrc32("11bbccdd")
         .AddFileUploaded(true)
         .AddFileSpeed(200)
         .AddFileSize(2000000)
         .AddUserName("user2")
         .AddGroupName("group2");
     race.AddRaceStats(raceStats);
     Assert.AreEqual(3, race.TotalFilesUploaded, "TotalFilesUploaded");
     Assert.AreEqual ((UInt64) 6000000, race.TotalBytesUploaded, "TotalBytesUploaded");
     Assert.AreEqual ((UInt64) 5, race.TotalMegaBytesUploaded, "TotalMegaBytesUploaded");
     Assert.AreEqual (2, race.TotalGroupsRacing, "TotalGroupsRacing");
     Assert.AreEqual (3, race.TotalUsersRacing, "TotalUsersRacing");
     Assert.AreEqual (3, race.GetUserStats ().Count, "GetUserStats");
     Assert.AreEqual(2, race.GetGroupStats().Count, "GetGroupStats");
     List<RaceStatsUsers> statsUsers = race.GetUserStats();
     Assert.That(statsUsers, Is.Ordered.Descending);
     //Assert.Sorted(statsUsers, SortOrder.Decreasing);
     List<RaceStatsGroups> statsGroups = race.GetGroupStats ();
     Assert.That(statsGroups, Is.Ordered.Descending);
     //Assert.Sorted(statsGroups, SortOrder.Decreasing);
     //Console
     foreach (RaceStatsUsers raceStatsUser in statsUsers)
     {
         Console.WriteLine(raceStatsUser);
     }
     foreach (RaceStatsGroups raceStatsGroups in statsGroups)
     {
         Console.WriteLine(raceStatsGroups);
     }
 }