public void PrepareKeysForModset_MultipleModTypesAllWithBikeys_CorrectBikeysCopied()
        {
            var modset = ModsetHelpers.CreateTestModset(_fixture, _modsDirectory);

            foreach (var mod in modset.Mods)
            {
                CreateDirectoryForMod(_fileSystem, mod);
            }

            var keysPreparer = _serviceProvider.GetService <IKeysPreparer>() !;

            var result = keysPreparer.PrepareKeysForModset(modset);

            using (new AssertionScope())
            {
                result.ShouldBeSuccess();

                var expectedBikeyNames = GetBikeysForMods(_fileSystem, modset.ClientLoadableMods)
                                         .Append(new BikeyFile(KeysConstants.ArmaKey))
                                         .Select(x => x.FileName)
                                         .ToList();

                AssertCorrectBikeysInDirectory(
                    _fileSystem,
                    _keysDirectory,
                    expectedBikeyNames);
            }
        }
        public DedicatedServerTests()
        {
            _modset = ModsetHelpers.CreateTestModset(_fixture);

            _modsetConfigMock
            .Setup(x => x.CopyConfigFiles())
            .Returns(Result.Success);
        }
예제 #3
0
        public async Task PrepareModset_AllModsExistAndAreUpToDate_NothingHappens()
        {
            var modset            = ModsetHelpers.CreateTestModset(_fixture);
            var cancellationToken = CancellationToken.None;

            AddModsToModsCache(modset.Mods.ToList());
            SetModsAsUpToDate(modset.Mods.ToList());

            await _modsManager.PrepareModset(modset, cancellationToken);

            VerifyModsNotDownloadedOrUpdated();
            VerifyModsCacheNotUpdated();
        }
예제 #4
0
        public void GetStartupParams_AllParametersCorrect_AllParametersIncluded()
        {
            var hcProfileDirectory = _fixture.Create <string>();
            var serverCfgPath      = _fixture.Create <string>();
            var basicCfgPath       = _fixture.Create <string>();
            var port           = _fixture.Create <int>();
            var serverPassword = _fixture.Create <string>();

            var modset = ModsetHelpers.CreateTestModset(_fixture);
            var requiredAndServerModsDirectories = modset.ServerSideMods
                                                   .Concat(modset.RequiredMods)
                                                   .GetDirectories();

            var modsetConfigMock = new Mock <IModsetConfig>();

            modsetConfigMock.Setup(x => x.HCProfileDirectory).Returns(hcProfileDirectory);
            modsetConfigMock.Setup(x => x.ServerCfg).Returns(serverCfgPath);
            modsetConfigMock.Setup(x => x.BasicCfg).Returns(basicCfgPath);
            modsetConfigMock.Setup(x => x.ServerPassword).Returns(serverPassword);

            var parametersProvider = new HeadlessParametersProvider(
                port,
                modset,
                modsetConfigMock.Object);

            var startupParams = parametersProvider.GetStartupParams(string.Empty);

            startupParams.GetProcessStartInfo().Arguments.Should()
            .Contain("-client")
            .And.Subject.Should()
            .Contain("-connect=127.0.0.1")
            .And.Subject.Should()
            .Contain($"port={port}")
            .And.Subject.Should()
            .Contain($"-password={serverPassword}")
            .And.Subject.Should()
            .Contain($"-profiles=\"{hcProfileDirectory}\"")
            .And.Subject.Should()
            .Contain($"-mod={string.Join(";", requiredAndServerModsDirectories)}")
            .And.Subject.Should()
            .NotContain("-serverMod=");
        }
예제 #5
0
        public async Task PrepareModset_SomeModsOutdated_UpdatedOutdatedMods()
        {
            var modset            = ModsetHelpers.CreateTestModset(_fixture);
            var cancellationToken = CancellationToken.None;

            var outdatedMods = modset.Mods
                               .Take(5)
                               .ToList();
            var upToDateMods = modset.Mods
                               .Except(outdatedMods)
                               .ToList();

            AddModsToModsCache(modset.Mods.ToList());
            SetModsAsUpToDate(upToDateMods);
            SetupContentDownloader(outdatedMods);

            await _modsManager.PrepareModset(modset, cancellationToken);

            VerifyModsDownloadedOrUpdated(outdatedMods, cancellationToken);
            VerifyModsCacheUpdated(outdatedMods);
        }
예제 #6
0
        public void GetStartupParams_AllParametersCorrect_AllParametersIncluded()
        {
            var serverProfileDirectory = _fixture.Create <string>();
            var serverCfgPath          = _fixture.Create <string>();
            var basicCfgPath           = _fixture.Create <string>();
            var port = _fixture.Create <int>();

            var modset = ModsetHelpers.CreateTestModset(_fixture);
            var serverModsDirectories = modset.ServerSideMods
                                        .Select(x => x.Directory);
            var requiredModsDirectories = modset.RequiredMods
                                          .Select(x => x.Directory);

            var modsetConfigMock = new Mock <IModsetConfig>();

            modsetConfigMock.Setup(x => x.ServerProfileDirectory).Returns(serverProfileDirectory);
            modsetConfigMock.Setup(x => x.ServerCfg).Returns(serverCfgPath);
            modsetConfigMock.Setup(x => x.BasicCfg).Returns(basicCfgPath);

            var parametersProvider = new ServerParametersProvider(
                port,
                modset,
                modsetConfigMock.Object);

            var startupParams = parametersProvider.GetStartupParams(string.Empty);

            startupParams.GetProcessStartInfo().Arguments.Should()
            .Contain($"port={port}")
            .And.Subject.Should()
            .Contain($"-config={serverCfgPath}")
            .And.Subject.Should()
            .Contain($"-cfg={basicCfgPath}")
            .And.Subject.Should()
            .Contain($"-profiles=\"{serverProfileDirectory}\"")
            .And.Subject.Should()
            .Contain($"-mod={string.Join(";", requiredModsDirectories)}")
            .And.Subject.Should()
            .Contain($"-serverMod={string.Join(";", serverModsDirectories)}");
        }