Exemplo n.º 1
0
        public void CanParse_inline_edge_case_should_not_parse()
        {
            DISetup.SetupContainer();

            var sb = new StringBuilder();

            sb.AppendLine(@"create_envoys = {		create_ship = { name = random graphical_culture = ""ehof_01"" design = ""NAME_Compound_Envoy"" } }");

            var args = new CanParseArgs()
            {
                File  = "common\\gamerules\\test.txt",
                Lines = sb.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries),
            };
            var parser = new KeyParser(new CodeParser(new Logger()), null);
            var result = parser.CanParse(args);

            result.Should().BeFalse();
        }
Exemplo n.º 2
0
        public void CanParse_inline_edge_case_should_parse()
        {
            DISetup.SetupContainer();

            var sb = new StringBuilder();

            sb.AppendLine(@"entity = { name = ""ai_01_blue_sponsored_colonizer_entity"" clone = ""ai_01_blue_colonizer_entity"" }");

            var args = new CanParseArgs()
            {
                File  = "common\\gamerules\\test.txt",
                Lines = sb.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries),
            };
            var parser = new KeyParser(new CodeParser(new Logger()), null);
            var result = parser.CanParse(args);

            result.Should().BeTrue();
        }
Exemplo n.º 3
0
        public void Should_overwrite_and_return_same_mod_collection_objects()
        {
            DISetup.SetupContainer();
            var col = new List <IModCollection>()
            {
                new ModCollection()
                {
                    Name = "fake2"
                }
            };
            var storage = new Storage(GetDbMock(), DIResolver.Get <IMapper>());

            storage.SetModCollections(col);
            var result = storage.GetModCollections();

            result.Count().Should().Be(1);
            result.First().Name.Should().Be(col.First().Name);
        }
        public void Data_without_prefix_should_be_empty()
        {
            DISetup.SetupContainer();
            var locManager = new Mock <ILocalizationManager>();

            locManager.Setup(s => s.GetResource(It.Is <string>(s => s == "test"))).Returns("test localization");
            DISetup.Container.RegisterInstance(locManager.Object);
            var invocation = new Mock <Castle.DynamicProxy.IInvocation>();

            invocation.Setup(p => p.InvocationTarget).Returns(new FakeModel()
            {
                DependendProperty = "test2"
            });
            var args    = new AttributeHandlersArgs(new DynamicLocalizationAttribute("DependendProperty"), invocation.Object, null, null);
            var handler = new DynamicLocalizationAttributeHandler();

            handler.GetData(args).Should().BeNull();
        }
Exemplo n.º 5
0
        public void Should_overwrite_and_return_same_game_settings_objects()
        {
            DISetup.SetupContainer();
            var col = new List <IGameSettings>()
            {
                new GameSettings()
                {
                    Type = "fake2"
                }
            };
            var storage = new Storage(GetDbMock(), DIResolver.Get <IMapper>());

            storage.SetGameSettings(col);
            var result = storage.GetGameSettings();

            result.Count().Should().Be(1);
            result.First().Type.Should().Be(col.First().Type);
        }
        public void Parse_should_yield_results()
        {
            DISetup.SetupContainer();

            var sb = new StringBuilder();

            sb.AppendLine(@"test1");
            sb.AppendLine(@"test2");

            var args = new ParserArgs()
            {
                ContentSHA      = "sha",
                ModDependencies = new List <string> {
                    "1"
                },
                File    = "common\\graphicalculturetype.txt",
                Lines   = sb.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries),
                ModName = "fake"
            };
            var parser = new WholeTextParser(new CodeParser(new Logger()), null);
            var result = parser.Parse(args).ToList();

            result.Should().NotBeNullOrEmpty();
            result.Count.Should().Be(1);
            for (int i = 0; i < 1; i++)
            {
                result[i].ContentSHA.Should().Be("sha");
                result[i].Dependencies.First().Should().Be("1");
                result[i].File.Should().Be("common\\graphicalculturetype.txt");
                switch (i)
                {
                case 0:
                    result[i].Code.Trim().Should().Be(sb.ToString().Trim());
                    result[i].Id.Should().Be("graphicalculturetype.txt");
                    result[i].ValueType.Should().Be(ValueType.WholeTextFile);
                    break;

                default:
                    break;
                }
                result[i].ModName.Should().Be("fake");
                result[i].Type.Should().Be("common\\txt");
            }
        }
        public void Parse_inline_should_yield_results()
        {
            DISetup.SetupContainer();

            var sb = new StringBuilder();

            sb.AppendLine("NTest.Path.SubPath = 10");

            var args = new ParserArgs()
            {
                ContentSHA      = "sha",
                ModDependencies = new List <string> {
                    "1"
                },
                File    = "common\\defines\\t.txt",
                Lines   = sb.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries),
                ModName = "fake"
            };
            var parser = new Generic.DefinesParser(new CodeParser(new Logger()), null);
            var result = parser.Parse(args).ToList();

            result.Should().NotBeNullOrEmpty();
            result.Count.Should().Be(1);
            for (int i = 0; i < 1; i++)
            {
                result[i].ContentSHA.Should().Be("sha");
                result[i].Dependencies.First().Should().Be("1");
                result[i].File.Should().Be("common\\defines\\t.txt");
                switch (i)
                {
                case 0:
                    result[i].Id.Should().Be("SubPath");
                    result[i].ValueType.Should().Be(ValueType.SpecialVariable);
                    result[i].Type.Should().Be("common\\defines\\NTest.Path-txt");
                    result[i].Code.Should().Be("NTest.Path.SubPath = 10");
                    break;

                default:
                    break;
                }
                result[i].ModName.Should().Be("fake");
            }
        }
Exemplo n.º 8
0
        public async Task Should_not_install_mods_when_no_game()
        {
            DISetup.SetupContainer();

            var storageProvider = new Mock <IStorageProvider>();
            var modParser       = new Mock <IModParser>();
            var reader          = new Mock <IReader>();
            var modWriter       = new Mock <IModWriter>();
            var gameService     = new Mock <IGameService>();
            var mapper          = new Mock <IMapper>();

            var service = GetService(storageProvider, modParser, reader, mapper, modWriter, gameService);

            gameService.Setup(p => p.GetSelected()).Returns((IGame)null);

            var result = await service.InstallModsAsync(null);

            result.Should().BeNull();
        }
        public void Should_return_supported_name_block_font_family()
        {
            DISetup.SetupContainer();
            var fontManager     = new Mock <IFontFamilyManager>();
            var languageService = new Mock <ILanguagesService>();
            var family          = new NotoSansSCFontFamily();

            fontManager.Setup(s => s.ResolveFontFamily(It.Is <string>(s => s == "test"))).Returns(family);
            languageService.Setup(p => p.GetLanguageBySupportedNameBlock(It.IsAny <string>())).Returns(new Language()
            {
                Abrv = "en",
                Font = "test"
            });
            DISetup.Container.RegisterInstance(fontManager.Object);
            var converter = new FontFamilyConverter();
            var result    = converter.Convert("test", null, null, null);

            result.Should().Be(family.GetFontFamily());
        }
Exemplo n.º 10
0
        public void Should_be_achievement_compatible()
        {
            DISetup.SetupContainer();

            var storageProvider = new Mock <IStorageProvider>();
            var modParser       = new Mock <IModParser>();
            var reader          = new Mock <IReader>();
            var modWriter       = new Mock <IModWriter>();
            var gameService     = new Mock <IGameService>();
            var mapper          = new Mock <IMapper>();

            gameService.Setup(p => p.GetSelected()).Returns(new Game()
            {
                Type              = "Should_be_achievement_compatible",
                UserDirectory     = "C:\\Users\\Fake",
                WorkshopDirectory = "C:\\workshop",
                ChecksumFolders   = new List <string>()
                {
                    "common", "events"
                }
            });
            reader.Setup(p => p.GetFiles(It.IsAny <string>())).Returns(new List <string>()
            {
                "test"
            });
            var service = GetService(storageProvider, modParser, reader, mapper, modWriter, gameService);

            var mod = new Mod()
            {
                IsValid = true,
                Files   = new List <string>()
                {
                    "gfx\\pop_jobs\\file.txt", "localisation\\yml.yml"
                }
            };
            var result = service.EvalAchievementCompatibility(new List <IMod>()
            {
                mod
            });

            result.Should().Be(true);
            mod.AchievementStatus.Should().Be(AchievementStatus.Compatible);
        }
Exemplo n.º 11
0
        public void Should_add_and_return_added_theme()
        {
            DISetup.SetupContainer();
            var dbMock      = GetDbMock();
            var newThemeKey = "test2";
            var mapper      = new Mock <IMapper>();

            mapper.Setup(p => p.Map <List <IThemeType> >(It.IsAny <IEnumerable <IThemeType> >())).Returns(() =>
            {
                return(dbMock.Themes.ToList());
            });
            var storage = new Storage(dbMock, mapper.Object);

            storage.RegisterTheme(newThemeKey);
            var themes = storage.GetThemes();

            themes.Count().Should().Be(2);
            themes.FirstOrDefault(p => p.Name == newThemeKey).Should().NotBeNull();
        }
Exemplo n.º 12
0
        public async Task Should_not_delete_descriptors_when_no_game()
        {
            DISetup.SetupContainer();

            var storageProvider = new Mock <IStorageProvider>();
            var modParser       = new Mock <IModParser>();
            var reader          = new Mock <IReader>();
            var modWriter       = new Mock <IModWriter>();
            var gameService     = new Mock <IGameService>();
            var mapper          = new Mock <IMapper>();

            var service = GetService(storageProvider, modParser, reader, mapper, modWriter, gameService);

            gameService.Setup(p => p.GetSelected()).Returns((IGame)null);

            var result = await service.DeleteDescriptorsAsync(new List <IMod>());

            result.Should().BeFalse();
        }
Exemplo n.º 13
0
        public async Task Mod_directory_should_not_purge_when_no_game()
        {
            DISetup.SetupContainer();

            var storageProvider = new Mock <IStorageProvider>();
            var modParser       = new Mock <IModParser>();
            var reader          = new Mock <IReader>();
            var modWriter       = new Mock <IModWriter>();
            var gameService     = new Mock <IGameService>();
            var mapper          = new Mock <IMapper>();

            var service = GetService(storageProvider, modParser, reader, mapper, modWriter, gameService);

            gameService.Setup(p => p.GetSelected()).Returns((IGame)null);

            var result = await service.PurgeModDirectoryAsync("test");

            result.Should().BeFalse();
        }
        public void Should_create_empty_mod_collection_object()
        {
            DISetup.SetupContainer();
            var storageProvider = new Mock <IStorageProvider>();
            var mapper          = new Mock <IMapper>();
            var gameService     = new Mock <IGameService>();
            var modExport       = new Mock <IModCollectionExporter>();

            SetupMockCase(storageProvider, gameService);

            var service = new ModCollectionService(null, null, new Cache(), null, null, null, null, gameService.Object, modExport.Object, storageProvider.Object, mapper.Object);
            var result  = service.Create();

            result.Name.Should().BeNullOrEmpty();
            result.Mods.Should().NotBeNull();
            result.Mods.Count().Should().Be(0);
            result.IsSelected.Should().BeFalse();
            result.Game.Should().Be("test");
        }
Exemplo n.º 15
0
        public async Task Should_not_import_hash()
        {
            var storageProvider    = new Mock <IStorageProvider>();
            var mapper             = new Mock <IMapper>();
            var hashExport         = new Mock <IReportExportService>();
            var preferencesService = new Mock <IPreferencesService>();

            hashExport.Setup(p => p.GetGameReports(It.IsAny <IReadOnlyCollection <IHashReport> >())).Returns((IReadOnlyCollection <IHashReport> hashReports) =>
            {
                if (hashReports != null)
                {
                    return(hashReports.Where(p => p.ReportType == HashReportType.Game).ToList());
                }
                return(null);
            });
            hashExport.Setup(p => p.CompareReports(It.IsAny <IReadOnlyCollection <IHashReport> >(), It.IsAny <IReadOnlyCollection <IHashReport> >())).Returns((IReadOnlyCollection <IHashReport> first, IReadOnlyCollection <IHashReport> second) =>
            {
                return(null);
            });
            var messageBus = new Mock <IMessageBus>();

            messageBus.Setup(p => p.PublishAsync(It.IsAny <IMessageBusEvent>()));
            messageBus.Setup(p => p.Publish(It.IsAny <IMessageBusEvent>()));
            var reader = new Mock <IReader>();

            reader.Setup(p => p.GetFiles(It.IsAny <string>())).Returns(new List <string>()
            {
                "test\\test"
            });
            DISetup.SetupContainer();

            var service = new GameService(messageBus.Object, hashExport.Object, reader.Object, storageProvider.Object, preferencesService.Object, new Mock <IMapper>().Object);
            var result  = await service.ImportHashReportAsync(new Game()
            {
                GameFolders = new List <string>()
                {
                    "test"
                }
            }, null);

            result.Should().BeNull();
        }
        public void Class_should_be_copied_definition()
        {
            DISetup.SetupContainer();
            var converter = new DefinitionPriorityClassConverter();
            var service   = new Mock <IModPatchCollectionService>();

            service.Setup(p => p.IsPatchMod(It.IsAny <string>())).Returns((string p) =>
            {
                if (p == "IronyModManager_fake3")
                {
                    return(true);
                }
                return(false);
            });
            DISetup.Container.RegisterInstance(service.Object);
            var def = new Definition()
            {
                ModName = "IronyModManager_fake1", File = "test1.txt"
            };
            var def2 = new Definition()
            {
                ModName = "IronyModManager_fake2", File = "test1.txt"
            };
            var def3 = new Definition()
            {
                ModName = "IronyModManager_fake3", File = "test.txt"
            };

            service.Setup(p => p.EvalDefinitionPriority(It.IsAny <IEnumerable <IDefinition> >())).Returns(new PriorityDefinitionResult()
            {
                Definition = def
            });
            var result = converter.Convert(new List <object>()
            {
                new List <IDefinition>()
                {
                    def, def2, def3
                }, def
            }, null, null, null);

            result.Should().Be("CopiedDefinition");
        }
Exemplo n.º 17
0
        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");
        }
Exemplo n.º 18
0
        public void Should_not_support_user_control()
        {
            DISetup.SetupContainer();
            var resolver = new Mock <IViewResolver>();

            resolver.Setup(p => p.FormatUserControlName(It.IsAny <object>())).Returns(string.Empty);
            resolver.Setup(p => p.IsControl(It.IsAny <string>())).Returns(false);
            DISetup.Container.RegisterInstance(resolver.Object);
            var logger = new Mock <ILogger>();

            logger.Setup(p => p.Info(It.IsAny <string>()));
            logger.Setup(p => p.Error(It.IsAny <Exception>(), It.IsAny <string>()));
            DISetup.Container.RegisterInstance(logger.Object);

            var locator = new ViewLocator();
            var result  = locator.Build(new FakeVM());

            result.GetType().Should().Be(typeof(TextBlock));
            ((TextBlock)result).Text.Should().Contain("Not Supported");
        }
Exemplo n.º 19
0
        public void Should_refresh_property()
        {
            DISetup.SetupContainer();
            DISetup.Container.Register <FakeModel>();
            var model = DISetup.Container.GetInstance <FakeModel>();

            model.Dummy2 = new List <FakeLocalizableModel>()
            {
                new FakeLocalizableModel()
                {
                    FakeProp = "1"
                }
            };
            var changedEvents  = new List <string>();
            var changingEvents = new List <string>();
            var initialValue   = model.Dummy2.First().FakeProp;
            var finalValue     = string.Empty;

            model.Dummy2.First().PropertyChanged += (s, e) =>
            {
                changedEvents.Add(e.PropertyName);
            };
            model.Dummy2.First().PropertyChanging += (s, e) =>
            {
                changingEvents.Add(e.PropertyName);
            };
            var invocation = new Mock <Castle.DynamicProxy.IInvocation>();

            invocation.Setup(p => p.InvocationTarget).Returns(model);
            invocation.Setup(p => p.Proxy).Returns(model.Dummy2);
            var prop    = model.GetType().GetProperty("Dummy2");
            var args    = new LocalizationRefreshArgs(invocation.Object, prop);
            var handler = new LocalizationCollectionRefreshHandler();

            handler.Refresh(args);
            changedEvents.Count.Should().Be(2);
            changedEvents.GroupBy(s => s).Select(s => s.First()).Count().Should().Be(1);
            changingEvents.Count.Should().Be(2);
            changingEvents.GroupBy(s => s).Select(s => s.First()).Count().Should().Be(1);
            model.Dummy2.First().FakeProp.Should().Be(initialValue);
        }
Exemplo n.º 20
0
        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");
        }
Exemplo n.º 21
0
 /// <summary>
 /// Setups the mock fail case.
 /// </summary>
 /// <param name="locManager">The loc manager.</param>
 /// <param name="resourceProvider">The resource provider.</param>
 /// <param name="preferencesService">The preferences service.</param>
 private void SetupMockFailCase(Mock <ILocalizationManager> locManager, Mock <IDefaultLocalizationResourceProvider> resourceProvider, Mock <IPreferencesService> preferencesService)
 {
     DISetup.SetupContainer();
     CurrentLocale.SetCurrent("en");
     locManager.Setup(p => p.GetResource(It.IsAny <string>(), It.IsAny <string>())).Returns("Roboto");
     resourceProvider.Setup(p => p.GetAvailableLocales()).Returns(() =>
     {
         return(new List <string>()
         {
             "es", "de"
         });
     });
     preferencesService.Setup(p => p.Get()).Returns(() =>
     {
         return(new Preferences()
         {
             Locale = "en"
         });
     });
     preferencesService.Setup(p => p.Save(It.IsAny <IPreferences>())).Returns(true);
 }
Exemplo n.º 22
0
        public void Should_parse_mod_file()
        {
            DISetup.SetupContainer();

            var sb = new StringBuilder();

            sb.AppendLine(@"name=""AI Species Limit""");
            sb.AppendLine(@"path=""path""");
            sb.AppendLine(@"user_dir=""dir""");
            sb.AppendLine(@"replace_path=""replace""");
            sb.AppendLine(@"tags={");
            sb.AppendLine(@"	""Gameplay""");
            sb.AppendLine(@"	""Fixes""");
            sb.AppendLine(@"}");
            sb.AppendLine(@"picture=""thumbnail.png""");
            sb.AppendLine(@"supported_version=""2.5.*""");
            sb.AppendLine(@"remote_file_id=""1830063425""");
            sb.AppendLine(@"version = ""version""");
            sb.AppendLine(@"dependencies = {");
            sb.AppendLine(@"	""fake""");
            sb.AppendLine(@"}");

            var parser = new ModParser(new CodeParser(new Logger()));
            var result = parser.Parse(sb.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries));

            result.Dependencies.Count().Should().Be(1);
            result.Dependencies.First().Should().Be("fake");
            result.FileName.Should().Be("path");
            result.Name.Should().Be("AI Species Limit");
            result.Picture.Should().Be("thumbnail.png");
            result.RemoteId.Should().Be(1830063425);
            result.Tags.Count().Should().Be(2);
            result.Tags.First().Should().Be("Gameplay");
            result.Tags.Last().Should().Be("Fixes");
            result.Version.Should().Be("2.5.*");
            result.UserDir.Count().Should().Be(1);
            result.UserDir.FirstOrDefault().Should().Be("dir");
            result.ReplacePath.Count().Should().Be(1);
            result.ReplacePath.FirstOrDefault().Should().Be("replace");
        }
        public async Task Should_not_export_hash_report()
        {
            var storageProvider = new Mock <IStorageProvider>();
            var mapper          = new Mock <IMapper>();
            var gameService     = new Mock <IGameService>();
            var modExport       = new Mock <IModCollectionExporter>();
            var hashExport      = new Mock <IReportExportService>();
            var messageBus      = new Mock <IMessageBus>();

            messageBus.Setup(p => p.PublishAsync(It.IsAny <IMessageBusEvent>()));
            messageBus.Setup(p => p.Publish(It.IsAny <IMessageBusEvent>()));
            DISetup.SetupContainer();

            var service = new ModCollectionService(messageBus.Object, hashExport.Object, new Cache(), null, null, null, null, gameService.Object, modExport.Object, storageProvider.Object, mapper.Object);
            var result  = await service.ExportHashReportAsync(null, "test");

            result.Should().BeFalse();

            result = await service.ExportHashReportAsync(new List <IMod>(), string.Empty);

            result.Should().BeFalse();
        }
Exemplo n.º 24
0
        public void Should_overwrite_window_state_object()
        {
            DISetup.SetupContainer();
            var dbMock = GetDbMock();
            var state  = new WindowState()
            {
                Height = 300
            };
            var mapper = new Mock <IMapper>();

            mapper.Setup(p => p.Map <IWindowState>(It.IsAny <IWindowState>())).Returns((IWindowState s) =>
            {
                return(new WindowState()
                {
                    Height = s.Height
                });
            });
            var storage = new Storage(dbMock, mapper.Object);

            storage.SetWindowState(state);
            dbMock.WindowState.Height.Should().Be(state.Height);
        }
Exemplo n.º 25
0
        public void Should_overwrite_app_state_object()
        {
            DISetup.SetupContainer();
            var dbMock = GetDbMock();
            var state  = new AppState()
            {
                CollectionModsSearchTerm = "test2"
            };
            var mapper = new Mock <IMapper>();

            mapper.Setup(p => p.Map <IAppState>(It.IsAny <IAppState>())).Returns((IAppState s) =>
            {
                return(new AppState()
                {
                    CollectionModsSearchTerm = s.CollectionModsSearchTerm
                });
            });
            var storage = new Storage(dbMock, mapper.Object);
            var result  = storage.SetAppState(state);

            dbMock.AppState.CollectionModsSearchTerm.Should().Be(state.CollectionModsSearchTerm);
        }
Exemplo n.º 26
0
        public void Should_overwrite_preferences_object()
        {
            DISetup.SetupContainer();
            var dbMock  = GetDbMock();
            var newPref = new Preferences()
            {
                Locale = "test2"
            };
            var mapper = new Mock <IMapper>();

            mapper.Setup(p => p.Map <IPreferences>(It.IsAny <IPreferences>())).Returns((IPreferences s) =>
            {
                return(new Preferences()
                {
                    Locale = s.Locale
                });
            });
            var storage = new Storage(dbMock, mapper.Object);

            storage.SetPreferences(newPref);
            dbMock.Preferences.Locale.Should().Be(newPref.Locale);
        }
        public void Class_should_be_patch_mod()
        {
            DISetup.SetupContainer();
            var converter = new DefinitionPriorityClassConverter();
            var service   = new Mock <IModPatchCollectionService>();

            service.Setup(p => p.IsPatchMod(It.IsAny <string>())).Returns(true);
            DISetup.Container.RegisterInstance(service.Object);
            var def = new Definition()
            {
                ModName = "IronyModManager_fake"
            };
            var result = converter.Convert(new List <object>()
            {
                new List <IDefinition>()
                {
                    def
                }, def
            }, null, null, null);

            result.Should().Be("PatchMod");
        }
        public void Text_should_include_priority_type()
        {
            DISetup.SetupContainer();
            var service = new Mock <IModPatchCollectionService>();

            service.Setup(p => p.IsPatchMod(It.IsAny <string>())).Returns(false);
            DISetup.Container.RegisterInstance(service.Object);
            var converter = new DefinitionPriorityTextConverter();
            var def       = new Definition()
            {
                ModName = "IronyModManager_fake", Id = "t1"
            };
            var result = converter.Convert(new List <object>()
            {
                new List <IDefinition>()
                {
                    def
                }, def
            }, null, null, null);

            result.Should().Be("IronyModManager_fake - t1");
        }
Exemplo n.º 29
0
        public void Should_add_and_return_added_notification_position()
        {
            DISetup.SetupContainer();
            var dbMock  = GetDbMock();
            var newItem = new NotificationPositionType()
            {
                Position = Models.Common.NotificationPosition.TopLeft
            };
            var mapper = new Mock <IMapper>();

            mapper.Setup(p => p.Map <List <INotificationPositionType> >(It.IsAny <IEnumerable <INotificationPositionType> >())).Returns(() =>
            {
                return(dbMock.NotificationPosition.ToList());
            });
            var storage = new Storage(dbMock, mapper.Object);

            storage.RegisterNotificationPosition(newItem);
            var result = storage.GetNotificationPositions();

            result.Count().Should().Be(2);
            result.FirstOrDefault(p => p.Position == newItem.Position).Should().NotBeNull();
        }
Exemplo n.º 30
0
        public void Should_return_files()
        {
            DISetup.SetupContainer();
            DISetup.Container.Register <ITempFile, DummyTempFile>();
            DISetup.Container.RemoveTransientWarning <ITempFile>();
            DI.DIContainer.Finish(true);
            var preferencesService = new Mock <IPreferencesService>();
            var storageProvider    = new Mock <IStorageProvider>();
            var mapper             = new Mock <IMapper>();

            var service = new ExternalEditorService(preferencesService.Object, storageProvider.Object, mapper.Object);
            var result  = service.GetFiles(new Definition()
            {
                ModName = "m1", Id = "id1"
            }, new Definition()
            {
                ModName = "m2", Id = "id2"
            });

            result.LeftDiff.File.Should().Be("m1 - id1.tmp");
            result.RightDiff.File.Should().Be("m2 - id2.tmp");
        }