Пример #1
0
        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();
        }
Пример #2
0
        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());
        }
Пример #3
0
        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());
        }
Пример #4
0
        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());
        }
Пример #5
0
        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);
        }
Пример #6
0
        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());
        }