コード例 #1
0
ファイル: AddCommandTests.cs プロジェクト: sde-sw/propmgr
        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
ファイル: AddCommandTests.cs プロジェクト: sde-sw/propmgr
        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
ファイル: AddCommandTests.cs プロジェクト: sde-sw/propmgr
        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
ファイル: AddCommandTests.cs プロジェクト: sde-sw/propmgr
        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
ファイル: AddCommandTests.cs プロジェクト: sde-sw/propmgr
        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
ファイル: AddCommandTests.cs プロジェクト: sde-sw/propmgr
        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());
        }