public void NullCollection_ShouldNotThrow() { IUserConfirmation uc = new ThrowOnTriggerUserConfirmation(); var prop = new PropertyPair { Key = "A", Value = "a" }; ICommand cmd = new AddPropertyCommand(null, prop, uc); cmd.Execute(); }
public void NullProperty_ShouldNotEditEmptyCollection() { IPropertiesFile file = new InMemoryPropertiesFile(new List <PropertyPair>()); IUserConfirmation uc = new ThrowOnTriggerUserConfirmation(); ICommand cmd = new AddPropertyCommand(file, null, uc); cmd.Execute(); Assert.Empty(file.GetProperties()); }
public void ShouldAddIntoEmptyCollection() { IPropertiesFile file = new InMemoryPropertiesFile(new List <PropertyPair>()); IUserConfirmation uc = new ThrowOnTriggerUserConfirmation(); var prop = new PropertyPair { Key = "greeting", Value = "Hello, World!" }; ICommand cmd = new AddPropertyCommand(file, prop, uc); cmd.Execute(); var collection = file.GetProperties(); Assert.Single(collection); Assert.Same(prop, collection.First()); }
public void NullProperty_ShouldNotEditFilledCollection() { IPropertiesFile file = new InMemoryPropertiesFile(new List <PropertyPair> { new PropertyPair { Key = "A", Value = "a" }, new PropertyPair { Key = "B", Value = "b" } }); IUserConfirmation uc = new ThrowOnTriggerUserConfirmation(); ICommand cmd = new AddPropertyCommand(file, null, uc); cmd.Execute(); Assert.Equal(2, file.GetProperties().Count()); }
public void ShouldUpdateExistingIfKeyAlreadyExists() { IPropertiesFile file = new InMemoryPropertiesFile(new List <PropertyPair> { new PropertyPair { Key = "A", Value = "a" }, new PropertyPair { Key = "B", Value = "b" } }); IUserConfirmation uc = new ThrowOnTriggerUserConfirmation(); var prop = new PropertyPair { Key = "B", Value = "Hello, World!" }; ICommand cmd = new AddPropertyCommand(file, prop, uc); cmd.Execute(); Assert.Equal(2, file.GetProperties().Count()); Assert.Equal("Hello, World!", file.GetProperties().Last().Value); }
public void ShouldBeAddedAtTheEndOfCollection() { IPropertiesFile file = new InMemoryPropertiesFile(new List <PropertyPair> { new PropertyPair { Key = "A", Value = "a" }, new PropertyPair { Key = "B", Value = "b" } }); IUserConfirmation uc = new ThrowOnTriggerUserConfirmation(); var prop = new PropertyPair { Key = "greeting", Value = "Hello, World!" }; ICommand cmd = new AddPropertyCommand(file, prop, uc); cmd.Execute(); var collection = file.GetProperties(); Assert.Equal(3, collection.Count()); Assert.Same(prop, collection.Last()); }