public void PropertyBagHolder_GetPropertyOfT_ThrowsIfPropertyDoesNotExist() { var inputObject = new TestClass(); Action action = () => inputObject.GetProperty <int>(PropertyName); action.ShouldThrow <InvalidOperationException>().WithMessage($"*{PropertyName}*"); }
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(); }
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"); }
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"); }
public void PropertyBagHolder_GetPropertyOfT_WorksForStringProperties() { var inputObject = new TestClass(); inputObject.SetProperty(PropertyName, "x"); string value = inputObject.GetProperty <string>(PropertyName); value.Should().Be("x"); }
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); }