Exemple #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");
 }
 public void Process()
 {
     TagManager tagManager = new TagManager(race);
     CreateZipRaceDataFile();
     Output output = new Output(race);
     //output
     //    .Client(Config.ClientHead)
     //    .Client(Config.ClientFileName)
     //    .Client(Config.ClientFoot);
     tagManager.CreateTag(currentRaceData.DirectoryPath, output.Format(Config.TagIncomplete, null));
     tagManager.CreateSymLink(currentRaceData.DirectoryParent, output.Format(Config.TagIncompleteLink, null));
 }
 public void Process()
 {
     Log.Debug("Process with SFV");
     TagManager tagManager = new TagManager(race);
     Log.Debug("Create missing files");
     foreach (KeyValuePair<string, string> keyValuePair in sfvData)
     {
         FileInfo.Create0ByteFile(Misc.PathCombine(currentRaceData.DirectoryPath, keyValuePair.Key + Config.FileExtensionMissing));
     }
     race.TotalFilesExpected = sfvData.Count;
     Log.Debug("Total files expected: {0}", race.TotalFilesExpected);
     CreateSfvRaceDataFile();
     Output output = new Output(race);
     output
         .Client(Config.ClientHead)
         .Client(Config.ClientFileNameSfv)
         .Client(Config.ClientFoot);
     Log.Debug("Create INCOMPLETE Symlinks");
     tagManager.CreateTag(currentRaceData.DirectoryPath, output.Format(Config.TagIncomplete));
     tagManager.CreateSymLink(currentRaceData.DirectoryParent, output.Format(Config.TagIncompleteLink));
     if (Config.LogToIoFtpdSfv)
     {
         Log.IoFtpd(output.Format(Config.LogLineIoFtpdSfv));
     }
     if (Config.LogToInternalSfv)
     {
         Log.Internal(output.Format(Config.LogLineInternalSfv));
     }
 }
Exemple #4
0
 public void Format()
 {
     Race race = new Race(new[] {"upload", @"..\..\TestFiles\Mp3\06-judas_priest-beyond_the_realms_of_death.mp3", "00000000", @"../../TestFiles/Mp3/06-judas_priest-beyond_the_realms_of_death.mp3"});
     race.ParseUpload();
     const int totalFilesExpected = 123;
     race.TotalFilesExpected = totalFilesExpected;
     bool isAudioRace = race.IsAudioRace;
     Assert.IsTrue(isAudioRace);
     Output output = new Output(race);
     File file = File.Create(@"..\..\TestFiles\Mp3\06-judas_priest-beyond_the_realms_of_death.mp3");
     Assert.AreEqual("06-judas_priest-beyond_the_realms_of_death.mp3", output.Format("{0}", file), "FileName");
     Assert.AreEqual("Mp3", output.Format("{1}", file), "DirectoryName");
     Assert.AreEqual("NoUser", output.Format("{2}", file), "UserName");
     Assert.AreEqual("NoGroup", output.Format("{3}", file), "GroupName");
     Assert.AreEqual("/NoPath", output.Format("{4}", file), "UploadVirtualPath");
     Assert.AreEqual(totalFilesExpected.ToString(), output.Format("{5}", file), "TotalFilesExpected");
     Assert.AreEqual("0", output.Format("{6}", file), "TotalFilesUploaded");
     Assert.AreEqual("0", output.Format("{7}", file), "TotalBytesUploaded");
     Assert.AreEqual("0", output.Format("{8}", file), "TotalMegaBytesUploaded");
     Assert.AreEqual("0B", output.Format("{9}", file), "TotalBytesUploadedFormated");
     Assert.AreEqual("0B", output.Format("{10}", file), "TotalBytesExpected");
     Assert.AreEqual("1", output.Format("{11}", file), "TotalAvarageSpeed");
     Assert.AreEqual("0", output.Format("{12}", file), "TotalUsersRacing");
     Assert.AreEqual("0", output.Format("{13}", file), "TotalGroupsRacing");
     Assert.AreEqual("-----------------", output.Format("{14}", file), "ProgressBar");
     Assert.AreEqual("0%", output.Format("{15}%", file), "PercentComplete");
     Assert.AreEqual(Constants.CodeIrcColor, output.Format("{16}", file), "CodeIrcColor");
     Assert.AreEqual(Constants.CodeIrcBold, output.Format("{17}", file), "CodeIrcBold");
     Assert.AreEqual(Constants.CodeIrcUnderline, output.Format("{18}", file), "CodeIrcUnderline");
     Assert.AreEqual(Constants.CodeNewLine, output.Format("{19}", file), "codeNewLine");
     Assert.AreEqual("Judas Priest", output.Format("{20}", file), "FirstPerformer");
     Assert.AreEqual("A Touch of Evil Live", output.Format("{21}", file), "Album");
     Assert.AreEqual("Beyond the Realms of Death", output.Format("{22}", file), "Title");
     Assert.AreEqual("Heavy Metal", output.Format("{23}", file), "FirstGenre");
     Assert.AreEqual("2009", output.Format("{24}", file), "Year");
     Assert.AreEqual("6", output.Format("{25}", file), "Track");
     Assert.AreEqual("1", output.Format("{26}", file), "Speed");
     Assert.AreEqual("231", output.Format("{27}", file), "AudioBitrate");
     Assert.AreEqual("2", output.Format("{28}", file), "AudioChannels");
     Assert.AreEqual("44100", output.Format("{29}", file), "AudioSampleRate");
     Assert.AreEqual("0", output.Format("{30}", file), "BitsPerSample");
     Assert.AreEqual("MPEG Version 1 Audio, Layer 3 VBR", output.Format("{31}", file), "Description");
     Assert.AreEqual("Audio", output.Format("{32}", file), "MediaTypes");
     Assert.AreEqual("MPEG Version 1 Audio, Layer 3 VBR", output.Format("{33}", file), "Codecs");
     Assert.AreEqual("00:06:51", output.Format("{34}", file), "Duration");
 }
        public void Process()
        {
            Output output = new Output(race);
            output
                .Client(Config.ClientHead)
                .Client(Config.ClientFileName)
                .Client(Config.ClientFoot);

            if (String.IsNullOrEmpty(imdbUrl))
            {
                return;
            }
            Log.Debug("Process IMDB info");
            race.CurrentRaceData.LinkImdb = imdbUrl;
            if (Config.LogToIoFtpdUpdateNfo)
            {
                Log.IoFtpd(output.Format(Config.LogLineIoFtpdUpdateNfo));
            }
            if (Config.LogToInternalUpdateNfo)
            {
                Log.Internal(output.Format(Config.LogLineInternalUpdateNfo));
            }
            string imdbId = Extensions.GetImdbId(imdbUrl);
            if (String.IsNullOrEmpty(imdbId))
            {
                return;
            }
            Dictionary<string, object> imdbResponse = Extensions.GetImdbResponseForEventId(imdbId);
            if (Config.LogToIoFtpdUpdateImdb)
            {
                Log.IoFtpd(output.FormatImdb(Config.LogLineIoFtpdUpdateImdb, imdbResponse));
            }
            if (Config.LogToInternalUpdateImdb)
            {
                Log.Internal(output.FormatImdb(Config.LogLineInternalUpdateImdb, imdbResponse));
            }
        }
Exemple #6
0
 public void Race()
 {
     CleanTestFilesOutput();
     UploadSfvFileMp3();
     Race race = new Race(ArgsMp3File1);
     race.ParseUpload();
     race.Process();
     Output output = new Output(race);
     FileInfo fileInfo = new FileInfo(Misc.PathCombine(race.CurrentRaceData.DirectoryPath, Config.FileNameRace));
     using (FileStream stream = new FileStream(fileInfo.FullName,
                                               FileMode.Open,
                                               FileAccess.Read,
                                               FileShare.None))
     {
         using (BinaryReader reader = new BinaryReader(stream))
         {
             stream.Seek(0, SeekOrigin.Begin);
             Assert.AreEqual(4, reader.ReadInt32(), "Total files count");
             stream.Seek(256 * 1, SeekOrigin.Begin);
             Assert.AreEqual("01-jozek.Pepek-2009-asd-Ind.mp3", reader.ReadString(), "FileName");
             Assert.AreEqual("2e04944c", reader.ReadString(), "CRC32");
             Assert.AreEqual(true, reader.ReadBoolean(), "File was uploaded");
             Assert.AreEqual((UInt64) 5000, reader.ReadUInt64(), "FileSize");
         }
     }
     Assert.AreEqual((UInt64) 5000, race.TotalBytesUploaded, "TotalBytesUploaded");
     Assert.AreEqual(4, race.TotalFilesExpected, "TotalFilesExpected");
     Assert.AreEqual(1, race.TotalFilesUploaded, "TotalFilesUploaded");
     Assert.IsFalse(
         File.Exists(@"..\..\TestFiles\Mp3\01-jozek.Pepek-2009-asd-Ind.mp3" + Config.FileExtensionMissing),
         "01-jozek.Pepek-2009-asd-Ind.mp3" + Config.FileExtensionMissing);
     Assert.IsTrue(
         Directory.Exists(Misc.PathCombine(race.CurrentRaceData.DirectoryParent, output.Format(Config.TagIncompleteLink))),
         "Symlink does not exist!");
     race = new Race(ArgsMp3File2);
     race.ParseUpload();
     race.Process();
     output = new Output(race);
     Assert.IsFalse(
         File.Exists(@"..\..\TestFiles\Mp3\02-jozek.Pepek-2009-asd-Ind.mp3" + Config.FileExtensionMissing),
         "02-jozek.Pepek-2009-asd-Ind.mp3" + Config.FileExtensionMissing);
     Assert.IsTrue(
         Directory.Exists(Misc.PathCombine(race.CurrentRaceData.DirectoryParent, output.Format(Config.TagIncompleteLink))),
         "Symlink does not exist!");
     race = new Race(ArgsMp3File3);
     race.ParseUpload();
     race.Process();
     output = new Output(race);
     Assert.IsFalse(
         File.Exists(@"..\..\TestFiles\Mp3\03-jozek.Pepek-2009-asd-Ind(2).mp3" + Config.FileExtensionMissing),
         "03-jozek.Pepek-2009-asd-Ind(2).mp3" + Config.FileExtensionMissing);
     Assert.IsTrue(
         Directory.Exists(Misc.PathCombine(race.CurrentRaceData.DirectoryParent, output.Format(Config.TagIncompleteLink))),
         "Symlink does not exist!");
     race = new Race(ArgsMp3File4);
     race.ParseUpload();
     race.Process();
     output = new Output(race);
     Assert.AreEqual(4, race.TotalFilesExpected, "TotalFilesExpected");
     Assert.AreEqual(4, race.TotalFilesUploaded, "TotalFilesUploaded");
     Assert.IsFalse(
         File.Exists(@"..\..\TestFiles\Mp3\04-jozek.Pepek-2009-asd-Ind(3).mp3" + Config.FileExtensionMissing),
         "04-jozek.Pepek-2009-asd-Ind(3).mp3" + Config.FileExtensionMissing);
     Assert.IsFalse(
         Directory.Exists(Misc.PathCombine(race.CurrentRaceData.DirectoryParent, output.Format(Config.TagIncompleteLink))),
         "Symlink not deleted!");
 }