Exemplo n.º 1
0
        public void LoadSettings_Existing_Settings_Test()
        {
            var expected = new ApplicationConfiguration
            {
                SteamExecutable   = "C:\\Program Files (x86)\\Steam\\Steam.exe",
                GameFolder        = "C:\\Program Files (x86)\\Steam\\SteamLibrary\\ConanExiles",
                ServerInformation =
                {
                    new ServerInformation {
                        Id = Guid.Parse("58C07C6F-1157-48A9-B6AC-4FDA52A95A00"), Name = "Shades & Fangs", Address = "51.89.70.206", Port = "7777", ModList = null
                    },
                    new ServerInformation {
                        Id = Guid.Parse("B4A80842-BC30-4D80-B7DA-E473DA81C13D"), Name = "The Green Isle", Address = "89.127.35.254", Port = "7777", ModList = null
                    },
                    new ServerInformation {
                        Id = Guid.Parse("8FC8AFD1-CA33-49D1-BC70-7E282DA7B661"), Name = "Rise of the Overlords", Address = "12.13.14.15", Port = "12345", ModList = null
                    },
                }
            };

            var settingsData = File.ReadAllText("Assets/ConanServerSwitcherSettings.json");
            var fs           = new Mock <IFileSystemService>();

            fs.Setup(f => f.Exists(It.IsAny <string>())).Returns(true);
            fs.Setup(f => f.ReadFileContent(It.IsAny <string>(), It.IsAny <Encoding>())).Returns(settingsData);

            var cs = new ApplicationConfigurationService(fs.Object);

            var result = cs.LoadConfiguration();

            result.Should().BeEquivalentTo(expected);
        }
Exemplo n.º 2
0
        public void LoadSettings_No_Existing_Settings_Test()
        {
            var expected = new ApplicationConfiguration();

            var fs = new Mock <IFileSystemService>();

            fs.Setup(f => f.Exists(It.IsAny <string>())).Returns(false);

            var cs = new ApplicationConfigurationService(fs.Object);

            var result = cs.LoadConfiguration();

            result.Should().BeEquivalentTo(expected);
        }