예제 #1
0
        public void PropertyBagHolder_SetProperty_OverwritesExistingProperty()
        {
            var inputObject = new TestClass();

            inputObject.SetProperty(PropertyName, "x");

            inputObject.SetProperty(PropertyName, 2);

            inputObject.PropertyNames.Count.Should().Be(1);
            inputObject.ShouldContainProperty(PropertyName);
            inputObject.GetProperty <int>(PropertyName).Should().Be(2);
        }
예제 #2
0
        public void PropertyBagHolder_TryGetPropertyOfT_ReturnsTrueWhenPropertyExists()
        {
            var inputObject = new TestClass();

            inputObject.SetProperty(PropertyName, 42);

            inputObject.TryGetProperty <int>(PropertyName, out int value).Should().BeTrue();
            value.Should().Be(42);
        }
예제 #3
0
        public void PropertyBagHolder_TryGetProperty_ReturnsTrueWhenPropertyExists()
        {
            var inputObject = new TestClass();

            inputObject.SetProperty(PropertyName, "x");

            inputObject.TryGetProperty(PropertyName, out string value).Should().BeTrue();
            value.Should().Be("x");
        }
예제 #4
0
        public void PropertyBagHolder_SetProperty_WorksWithNull()
        {
            var inputObject = new TestClass();

            inputObject.SetProperty <string>(PropertyName, null);

            inputObject.PropertyNames.Count.Should().Be(1);
            inputObject.ShouldContainProperty(PropertyName);
            inputObject.GetProperty(PropertyName).Should().BeNull();
        }
예제 #5
0
        public void PropertyBagHolder_SetProperty_EscapesCharacters()
        {
            var inputObject = new TestClass();

            inputObject.SetProperty(PropertyName, @"\r""\t");

            inputObject.PropertyNames.Count.Should().Be(1);
            inputObject.ShouldContainProperty(PropertyName);
            inputObject.GetProperty(PropertyName).Should().Be(@"\\r\""\\t");
        }
예제 #6
0
        public void PropertyBagHolder_SetProperty_AddsSpecifiedProperty()
        {
            var inputObject = new TestClass();

            inputObject.SetProperty(PropertyName, "x");

            inputObject.PropertyNames.Count.Should().Be(1);
            inputObject.ShouldContainProperty(PropertyName);
            inputObject.GetProperty(PropertyName).Should().Be("x");
        }
예제 #7
0
        public void PropertyBagHolder_GetPropertyOfT_WorksForStringProperties()
        {
            var inputObject = new TestClass();

            inputObject.SetProperty(PropertyName, "x");

            string value = inputObject.GetProperty <string>(PropertyName);

            value.Should().Be("x");
        }
예제 #8
0
        public void PropertyBagHolder_RemoveProperty_RemovesExistingProperty()
        {
            var inputObject = new TestClass();

            inputObject.SetProperty(PropertyName, "x");

            inputObject.RemoveProperty(PropertyName);

            inputObject.PropertyNames.Count.Should().Be(0);
            inputObject.ShouldNotContainProperty(PropertyName);
        }