public void ReturnMovieWithAplhabeticallyPriority()
        {
            var starWars = new Movie
            {
                Id     = "t0001",
                Title  = "Star Wars",
                Year   = 1977,
                Rating = 8.6f
            };

            var cityOfGod = new Movie
            {
                Id     = "t0002",
                Title  = "City Of God",
                Year   = 2002,
                Rating = 8.6f
            };


            var alphabeticalyWinner = MovieExtensions.CompareMovies(
                starWars,
                cityOfGod
                );


            Assert.Equal(alphabeticalyWinner, cityOfGod);
        }
        public void ReturnMovieWithHighestScore()
        {
            var theMatrix = new Movie
            {
                Id     = "t0001",
                Title  = "The Matrix",
                Year   = 1999,
                Rating = 8.7f
            };

            var fightClub = new Movie
            {
                Id     = "t0002",
                Title  = "Fight Club",
                Year   = 1999,
                Rating = 8.8f
            };


            var winner  = MovieExtensions.CompareMovies(theMatrix, fightClub);
            var winner2 = MovieExtensions.CompareMovies(fightClub, theMatrix);


            Assert.Equal(winner, winner2);
            Assert.Equal(fightClub, winner);
        }
        public void ReturnFirstPhaseWinners()
        {
            var movies = new Movie[]
            {
                MoviesMock.osIncriveis2,
                MoviesMock.jurassicWorldReinoAmeaçado,
                MoviesMock.oitoMulheresEUmSegredo,
                MoviesMock.hereditario,
                MoviesMock.vingadoresGuerraInfinita,
                MoviesMock.deadpool2,
                MoviesMock.hanSoloUmaHistoriaStarWars,
                MoviesMock.thorRagnarok
            };

            var expectedWinners = new Movie[]
            {
                MoviesMock.vingadoresGuerraInfinita,
                MoviesMock.thorRagnarok,
                MoviesMock.osIncriveis2,
                MoviesMock.jurassicWorldReinoAmeaçado
            };


            var winners = MovieExtensions.GetFirstPhaseWinners(movies);


            Assert.Equal(winners, expectedWinners);
        }
        public void ReturnFilterdMovies()
        {
            var movies = new Movie[]
            {
                MoviesMock.vingadoresGuerraInfinita,
                MoviesMock.thorRagnarok,
                MoviesMock.osIncriveis2,
                MoviesMock.jurassicWorldReinoAmeaçado
            };

            var expectedWinners = new Movie[]
            {
                MoviesMock.vingadoresGuerraInfinita,
                MoviesMock.osIncriveis2
            };


            var actualWinners = MovieExtensions.EliminatoryFilter(movies);


            Assert.Equal(expectedWinners, actualWinners);
        }
예제 #5
0
        public void ReturnWinner()
        {
            var movies = new Movie[]
            {
                MoviesMock.osIncriveis2,
                MoviesMock.jurassicWorldReinoAmeaçado,
                MoviesMock.oitoMulheresEUmSegredo,
                MoviesMock.hereditario,
                MoviesMock.vingadoresGuerraInfinita,
                MoviesMock.deadpool2,
                MoviesMock.hanSoloUmaHistoriaStarWars,
                MoviesMock.thorRagnarok
            };

            var expectedWinner   = MoviesMock.vingadoresGuerraInfinita;
            var expectedRunnerUp = MoviesMock.osIncriveis2;

            var expectedWinners = MovieExtensions.GetTournamentWinners(movies);
            var actualWinner    = expectedWinners.Winner;
            var actualRunnerUp  = expectedWinners.RunnerUp;

            Assert.Equal(expectedWinner, actualWinner);
            Assert.Equal(expectedRunnerUp, actualRunnerUp);
        }
예제 #6
0
파일: SubSet.cs 프로젝트: niilante/SubSet
        public async Task SetSubtitles()
        {
            if (Status != SubSetStatus.Idle)
            {
                throw new Exception();
            }
            await Task.Run(() =>
            {
                Status        = SubSetStatus.Analize;
                StatusMessage = "Analizing";
                var allFiles  = Directory.GetFiles("*.*", SearchOption.AllDirectories);

                RunStatic();

                foreach (var file in allFiles)
                {
                    if (MovieExtensions.Any(e => e == file.Extension))
                    {
                        Movies.Add(new FileMovie(file));
                    }
                    if (SubExtensions.Any(e => e == file.Extension))
                    {
                        Subs.Add(new FileSubtitle(file));
                    }
                    if (FontExtensions.Any(e => e == file.Extension))
                    {
                        Fonts.Add(new FileFont(file));
                    }
                }

                if (!Setting.SearchMovieInSubdir)
                {
                    Movies = Movies.Where(movie => movie.DirectoryPath == Directory.FullName).ToList();
                }
                if (!Setting.SearchSubInSubdir)
                {
                    Subs = Subs.Where(sub => sub.DirectoryPath == Directory.FullName).ToList();
                }

                StatusPercent = 10;

                foreach (var fontFile in Fonts)
                {
                    fontFile.Install();
                }
                StatusPercent = 20;
                SetEpizodes(Subs);
                StatusPercent = 50;
                SetEpizodes(Movies);
                StatusPercent = 80;
                foreach (var sub in Subs)
                {
                    sub.Movie = Movies.FirstOrDefault(m => m.Epizode == sub.Epizode && sub.Path.Contains(m.DirectoryPath));
                }
                StatusPercent = 90;
                StatusPercent = 0;
                Status        = SubSetStatus.SettingSub;
                StatusMessage = "RenamingSubs";
                for (int i = 0; i < Subs.Count; i++)
                {
                    var sub = Subs[i];
                    if (sub.Movie == null)
                    {
                        continue;
                    }
                    var subPath = Path.Combine(sub.Movie.DirectoryPath, sub.Movie.PureName + sub.Extension);
                    if (File.Exists(subPath))
                    {
                        continue;
                    }
                    sub.Info.MoveTo(subPath);
                    StatusPercent = (byte)(i * 100 / Subs.Count);
                }
                Status        = SubSetStatus.Completed;
                StatusPercent = 100;
                StatusMessage = "Completed";
            });
        }
예제 #7
0
 private PPDSetting(bool isDebug, string songDir, string langIso, bool disableExpansion, bool disableShader)
 {
     SongDir       = "songs";
     FontName      = "IPAGothic";
     LangISO       = "jp";
     FontSizeRatio = 30;
     BaseSize      = 32;
     CoolArea      = 0.04f;
     GoodArea      = 0.08f;
     SafeArea      = 0.12f;
     SadArea       = 0.15f;
     if (File.Exists(settingFileName))
     {
         var sr = new StreamReader(settingFileName);
         var s  = sr.ReadToEnd();
         sr.Close();
         var setting = new SettingReader(s);
         MultiSample     = (MultisampleType)GetValue(setting.ReadString("multisample"), 0);
         SkinName        = setting.ReadString("skinname");
         AdjustGapTime   = GetValue(setting.ReadString("adjustgaptime"), 0);
         FontName        = setting.ReadString("fontname");
         FontSizeRatio   = (int)GetValue(setting.ReadString("fontsize"), 32);
         Width           = (int)GetValue(setting.ReadString("width"), 800);
         Height          = (int)GetValue(setting.ReadString("height"), 450);
         MovieLatency    = GetValue(setting.ReadString("movielatency"), 0);
         MoviePlayType   = (MoviePlayType)((int)GetValue(setting.ReadString("movieplaytype"), 0));
         Token           = setting.ReadString("token");
         TokenSecret     = setting.ReadString("tokensecret");
         SongDir         = setting.ReadString("songdir");
         LangISO         = setting.ReadString("Language");
         TextBoxDisabled = setting.ReadString("textboxdisabled") == "1";
         DrawSameColorAtSameTimingDisabled = setting.ReadString("drawsamecoloratsametimingdisabled") == "1";
         FullScreen = setting.ReadString("fullscreen") == "1";
         if (SongDir == "")
         {
             SongDir = "songs";
         }
         MovieExtensions        = setting.ReadString("movieextensions").Split(';');
         MusicExtensions        = setting.ReadString("musicextensions").Split(';');
         AllowedToUseMuchMemory = setting.ReadString("allowedtousemuchmemory") == "1";
         IsDebug = setting.ReadString("IsDebug") == "1";
         DrawConnectUnderAllMark   = setting.ReadString("drawconnectunderallmark") == "1";
         EveryFramePollingDisabled = setting.ReadString("everyframepollingdisabled") == "1";
         MenuMoviePreviewDisabled  = setting.ReadString("menumoviepreviewdisabled") == "1";
         AccurateInputSleepTime    = (int)GetValue(setting.ReadString("accurateinputsleeptime"), 0);
         CollectLog                  = setting.ReadString("collectlog") == "1";
         RunExpansion                = setting.ReadString("runexpansion") == "1";
         ExpansionWaitPort           = setting.ReadInt("expansionwaitport", 54320);
         AutoAdjustLatencyDisabled   = setting.ReadBoolean("autoadjustlatencydisabled");
         ShaderDisabled              = setting.ReadBoolean("shaderdisabled");
         FontScaleDisabled           = setting.ReadBoolean("fontscaledisabled");
         HighResolutionImageDisabled = setting.ReadBoolean("highresolutionimagedisabled");
         TextureCharMode             = setting.ReadEnum <TextureCharMode>("texturecharmode", TextureCharMode.D2D);
     }
     else
     {
         MovieExtensions = new string[0];
         MusicExtensions = new string[0];
     }
     MovieExtensions = MovieExtensions.Select(e => e.ToLower()).ToArray();
     MusicExtensions = MusicExtensions.Select(e => e.ToLower()).ToArray();
     if (isDebug)
     {
         IsDebug = true;
         if (Directory.Exists(songDir))
         {
             SongDir = songDir;
         }
     }
     RunExpansion   &= !disableExpansion;
     ShaderDisabled |= disableShader;
     if (langIso != null)
     {
         LangISO = langIso;
     }
 }