Пример #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");
 }