public void Should_treat_close_separator_matches_as_search_text()
        {
            DISetup.SetupContainer();
            var registry = new LocalizationRegistry(new Cache());

            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Achievements, "en-ach");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Achievements, "fr-ach");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Selected, "en-sel");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Selected, "fr-sel");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Yes, "yes");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Yes, "fr-yes");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.True, "true");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.True, "fr-true");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.No, "no");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.No, "fr-no");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.False, "false");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.False, "fr-false");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Version, "en-ver");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Version, "fr-ver");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Source, "en-src");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Source, "fr-src");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Paradox, "pdx");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Paradox, "fr-pdx");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Steam, "steam");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Steam, "fr-steam");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Local, "local");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Local, "fr-local");

            var parser = new Mod.Search.Parser(new Logger(), new List <ITypeConverter <object> > {
                new VersionConverter(registry), new BoolConverter(registry), new SourceTypeConverter(registry)
            });
            var line   = "test:test";
            var result = parser.Parse("en", line);

            result.Should().NotBeNull();
            result.Name.Should().Be("test:test");

            line   = "test:test:test";
            result = parser.Parse("en", line);
            result.Should().NotBeNull();
            result.Name.Should().Be("test:test:test");
        }
        public void Should_be_able_to_convert_recognize_text_search()
        {
            DISetup.SetupContainer();
            var registry = new LocalizationRegistry(new Cache());

            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Achievements, "en-ach");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Achievements, "fr-ach");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Selected, "en-sel");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Selected, "fr-sel");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Yes, "yes");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Yes, "fr-yes");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.True, "true");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.True, "fr-true");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.No, "no");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.No, "fr-no");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.False, "false");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.False, "fr-false");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Version, "en-ver");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Version, "fr-ver");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Source, "en-src");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Source, "fr-src");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Paradox, "pdx");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Paradox, "fr-pdx");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Steam, "steam");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Steam, "fr-steam");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Local, "local");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Local, "fr-local");

            var parser = new Mod.Search.Parser(new Logger(), new List <ITypeConverter <object> > {
                new VersionConverter(registry), new BoolConverter(registry), new SourceTypeConverter(registry)
            });
            var line   = "test test";
            var result = parser.Parse("en", line);

            result.Should().NotBeNull();
            result.AchievementCompatible.Result.Should().BeNull();
            result.IsSelected.Result.Should().BeNull();
            result.Source.Result.Should().Be(Common.Mod.Search.SourceType.None);
            result.Version.Should().BeNull();
            result.Name.Should().Be("test test");
        }
        public void Should_filter_out_duplicates()
        {
            DISetup.SetupContainer();
            var registry = new LocalizationRegistry(new Cache());

            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Achievements, "en-ach");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Achievements, "fr-ach");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Selected, "en-sel");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Selected, "fr-sel");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Yes, "yes");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Yes, "fr-yes");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.True, "true");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.True, "fr-true");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.No, "no");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.No, "fr-no");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.False, "false");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.False, "fr-false");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Version, "en-ver");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Version, "fr-ver");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Source, "en-src");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Source, "fr-src");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Paradox, "pdx");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Paradox, "fr-pdx");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Steam, "steam");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Steam, "fr-steam");
            registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Local, "local");
            registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Local, "fr-local");

            var parser = new Mod.Search.Parser(new Logger(), new List <ITypeConverter <object> > {
                new VersionConverter(registry), new BoolConverter(registry), new SourceTypeConverter(registry)
            });
            var line   = "en-ach:yes && en-ach:no";
            var result = parser.Parse("en", line);

            result.Should().NotBeNull();
            result.AchievementCompatible.Result.GetValueOrDefault().Should().BeTrue();
        }