public void ReturnsTrueWhenPropertyExists() { var props = new ObjectWithProperties(); props.Properties["Key"] = "value"; props.ContainsProperty("Key").ShouldBeTrue(); }
public void ThrowsExceptionWhenKeyIsEmptyString() { var props = new ObjectWithProperties(); Should.Throw <ArgumentException>(() => props.ContainsProperty(string.Empty)); Should.Throw <ArgumentException>(() => props.ContainsProperty("")); }
public void ThrowsExcecptionWhenCanNotConvert() { var props = new ObjectWithProperties(); props.Properties["Key"] = "value"; Should.Throw <InvalidCastException>(() => props.GetPropertyValueAs <FakeType>("Key")); }
public void ThrowsExceptionWhenKeyIsNotFound() { var props = new ObjectWithProperties(); props.Properties["Key"] = "value"; Should.Throw <DynamicValueNotFoundException>(() => props.GetPropertyValueAs <string>("AnotheKey")); }
public void ThrowsExceptionWhenKeyIsNull() { var props = new ObjectWithProperties(); props.Properties["Key"] = "value"; Should.Throw <ArgumentNullException>(() => props.GetPropertyValueAs <string>(null)); }
public void ThrowsExceptionWhenKeyIsEmptyString() { var props = new ObjectWithProperties(); props.Properties["Key"] = "value"; Should.Throw <ArgumentException>(() => props.GetPropertyValueAs <string>(string.Empty)); Should.Throw <ArgumentException>(() => props.GetPropertyValueAs <string>("")); }
public void StoresAndReturnsValue() { var props = new ObjectWithProperties(); props.Properties["Key"] = "value"; var val = props.Properties["Key"]; Assert.True(val.Equals("value")); }
public void PropertyNotInitializedUntilFirstAccess() { var props = new ObjectWithProperties(); props.IsInitialized.ShouldBeFalse(); props.Properties["Key"] = "value"; props.IsInitialized.ShouldBeTrue(); }
public void CovertsBetweenTypes() { var props = new ObjectWithProperties(); props.Properties["MyNumber"] = 50; var val = props.GetPropertyValueAs <string>("MyNumber"); val.GetType().ShouldBe(typeof(string)); val.Equals("50").ShouldBeTrue(); }
public void ReturnsValueAsSpecifiedType() { var props = new ObjectWithProperties(); props.Properties["Key"] = "value"; var val = props.GetPropertyValueAs <string>("Key"); val.Equals("value").ShouldBeTrue(); val.GetType().ShouldBe(typeof(string)); }
public void ThrowsExceptionWhenIndexDoesNotExists() { var props = new ObjectWithProperties(); Should.Throw <KeyNotFoundException>(() => { var x = props.Properties["Key"]; }); }
public void ReturnsFalseWhenPropertyDoesNotExist() { var props = new ObjectWithProperties(); props.ContainsProperty("Key1").ShouldBeFalse(); }
public void ThrowsExceptionWhenKeyIsNull() { var props = new ObjectWithProperties(); Should.Throw <ArgumentNullException>(() => props.ContainsProperty(null)); }