Beispiel #1
0
        public void EditTest1()
        {
            // Arrange
            _clientConfiguration.Add("test", new LegacyClient {
                Settings = new ClientSettings(ClientType.Legacy)
                {
                    Name = "test", Path = "/home/harlam357/"
                }
            });
            Assert.AreEqual(1, _clientConfiguration.Count);
            ConfigurationChangedEventArgs eventArgs = null;

            _clientConfiguration.DictionaryChanged += (sender, e) => { eventArgs = e; };
            ClientEditedEventArgs editedEventArgs = null;

            _clientConfiguration.ClientEdited += (sender, e) => editedEventArgs = e;
            // Act
            _clientConfiguration.Edit("test", new ClientSettings(ClientType.Legacy)
            {
                Name = "test2", Path = "/home/harlam357/FAH/"
            });
            // Assert
            Assert.AreEqual(1, _clientConfiguration.Count);
            Assert.IsTrue(_clientConfiguration.ContainsKey("test2"));
            Assert.AreEqual(ConfigurationChangedType.Edit, eventArgs.ChangedType);
            Assert.AreEqual("test2", eventArgs.Client.Settings.Name);
            Assert.AreEqual("/home/harlam357/FAH/", eventArgs.Client.Settings.Path);
            Assert.AreEqual("test", editedEventArgs.PreviousName);
            Assert.AreEqual("/home/harlam357/", editedEventArgs.PreviousPath);
            Assert.AreEqual("test2", editedEventArgs.NewName);
            Assert.AreEqual("/home/harlam357/FAH/", editedEventArgs.NewPath);
        }
        public static bool TryGetValue(this ClientConfiguration configuration, string name, out string value)
        {
            value = null;
            if (!configuration.ContainsKey(name))
            {
                return(false);
            }

            value = configuration[name];
            return(true);
        }