コード例 #1
0
        public void Mixed_Settings_Read_Test()
        {
            // Arrange
            string tempPath     = Path.GetTempFileName();
            var    initSettings = new LibSettings(typeof(WakeOnLanCommandSettings).Assembly)
            {
                [_wakeOnLanCommandSettings[0].Id]        = _wakeOnLanCommandSettings[0],
                [_wakeOnLanCommandSettings[1].Id]        = _wakeOnLanCommandSettings[1],
                [_localNetworkHttpRequestSettings[0].Id] = _localNetworkHttpRequestSettings[0],
                [_wakeOnLanCommandSettings[2].Id]        = _wakeOnLanCommandSettings[2],
                [_localNetworkHttpRequestSettings[1].Id] = _localNetworkHttpRequestSettings[1]
            };

            // Act
            var settings = new LibSettings(typeof(WakeOnLanCommandSettings).Assembly);

            WakeOnLanCommandSettings[] wakeOnLanCommandSettings        = settings.GetValues(typeof(WakeOnLanCommandSettings)).Cast <WakeOnLanCommandSettings>().ToArray();
            HttpRequestSettings[]      localNetworkHttpRequestSettings = settings.GetValues(typeof(HttpRequestSettings)).Cast <HttpRequestSettings>().ToArray();

            // Assert
            Assert.AreEqual(initSettings.Length, 5);
            Assert.AreEqual(wakeOnLanCommandSettings.Length, 3);
            Assert.AreEqual(localNetworkHttpRequestSettings.Length, 2);
            Assert.AreEqual(settings.Length, 5);
            Assert.True(wakeOnLanCommandSettings.All(p => !string.IsNullOrEmpty(p.PcName)));
            Assert.True(localNetworkHttpRequestSettings.All(p => !string.IsNullOrEmpty(p.Url)));
            WakeOnLanCommandSettings wakeOnLanCommandSetting = settings[wakeOnLanCommandSettings[0].Id] as WakeOnLanCommandSettings;

            Assert.IsNotNull(wakeOnLanCommandSetting);
            Assert.AreEqual(wakeOnLanCommandSettings[0].Id, wakeOnLanCommandSetting.Id);
            Console.WriteLine(File.ReadAllText(tempPath));
        }
コード例 #2
0
        public void Mixed_Settings_Test()
        {
            // Arrange
            string tempPath = Path.GetTempFileName();

            // Act
            var settings = new LibSettings(typeof(WakeOnLanCommandSettings).Assembly)
            {
                [_wakeOnLanCommandSettings[0].Id]        = _wakeOnLanCommandSettings[0],
                [_wakeOnLanCommandSettings[1].Id]        = _wakeOnLanCommandSettings[1],
                [_localNetworkHttpRequestSettings[0].Id] = _localNetworkHttpRequestSettings[0],
                [_wakeOnLanCommandSettings[2].Id]        = _wakeOnLanCommandSettings[2],
                [_localNetworkHttpRequestSettings[1].Id] = _localNetworkHttpRequestSettings[1]
            };

            // Assert
            Assert.AreEqual(settings.GetValues(typeof(WakeOnLanCommandSettings)).Length, 3);
            Assert.AreEqual(settings.GetValues(typeof(HttpRequestSettings)).Length, 2);
            Assert.AreEqual(settings.Length, 5);
            Console.WriteLine(File.ReadAllText(tempPath));
        }