public void Should_not_convert() { var registry = new LocalizationRegistry(new Cache()); var converter = new VersionConverter(registry); var version = converter.Convert("en", "test"); version.Should().BeNull(); }
public void Should_convert() { var registry = new LocalizationRegistry(new Cache()); var converter = new VersionConverter(registry); var version = converter.Convert("en", "1.0"); version.Equals(new Version(1, 0)).Should().BeTrue(); }
public void Should_contain_registered_keys() { var registry = new LocalizationRegistry(new Cache()); registry.RegisterTranslation("en", registry.GetTranslationKeys().FirstOrDefault(), "test1"); registry.RegisterTranslation("fr", registry.GetTranslationKeys().FirstOrDefault(), "test2"); registry.GetTranslation("en", registry.GetTranslationKeys().FirstOrDefault()).Should().Be("test1"); registry.GetTranslation("fr", registry.GetTranslationKeys().FirstOrDefault()).Should().Be("test2"); registry.GetTranslations(registry.GetTranslationKeys().FirstOrDefault()).Count.Should().Be(2); }
public void Should_not_be_able_to_convert() { var registry = new LocalizationRegistry(new Cache()); registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Version, "en-ach"); registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Version, "fr-ach"); var converter = new VersionConverter(registry); converter.CanConvert("en", "en-fake").Result.Should().BeFalse(); }
public void Should_be_able_to_convert() { var registry = new LocalizationRegistry(new Cache()); registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Version, "en-ach"); registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Version, "fr-ach"); var converter = new VersionConverter(registry); converter.CanConvert("en", "en-ach").Result.Should().BeTrue(); converter.CanConvert("en", "en-ach").MappedStaticField.Should().Be(Fields.Version); converter.CanConvert("en", "fr-ach").Result.Should().BeTrue(); }
public void Should_not_be_able_to_convert() { var registry = new LocalizationRegistry(new Cache()); registry.RegisterTranslation("en", LocalizationResources.FilterCommands.Source, "en-ach"); registry.RegisterTranslation("fr", LocalizationResources.FilterCommands.Source, "fr-ach"); 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 converter = new SourceTypeConverter(registry); converter.CanConvert("en", "en-fake").Result.Should().BeFalse(); }
public void Should_not_be_able_to_convert() { 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.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"); var converter = new BoolConverter(registry); converter.CanConvert("en", "en-fake").Result.Should().BeFalse(); }
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(); }
public void Should_have_all_translation_keys() { var registry = new LocalizationRegistry(new Cache()); registry.GetTranslationKeys().Length.Should().Be(11); }