本文整理汇总了C#中PropertyBag.SetPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyBag.SetPropertyValue方法的具体用法?C# PropertyBag.SetPropertyValue怎么用?C# PropertyBag.SetPropertyValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyBag
的用法示例。
在下文中一共展示了PropertyBag.SetPropertyValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReturnsAllRegisteredPropertiesWithCorrectValues
public void ReturnsAllRegisteredPropertiesWithCorrectValues()
{
var propertyBag = new PropertyBag();
propertyBag.SetPropertyValue("FirstProperty", 1);
propertyBag.SetPropertyValue("SecondProperty", "test");
var allProperties = propertyBag.GetAllProperties().ToList();
Assert.AreEqual(2, allProperties.Count);
Assert.AreEqual("FirstProperty", allProperties[0].Key);
Assert.AreEqual(1, allProperties[0].Value);
Assert.AreEqual("SecondProperty", allProperties[1].Key);
Assert.AreEqual("test", allProperties[1].Value);
}
示例2: ReturnsTrueForRegisteredPropertyName
public void ReturnsTrueForRegisteredPropertyName()
{
var propertyBag = new PropertyBag();
propertyBag.SetPropertyValue("MyProperty", 1);
Assert.IsTrue(propertyBag.IsPropertyAvailable("MyProperty"));
}
示例3: ReturnsRightPropertyValue
public void ReturnsRightPropertyValue()
{
var propertyBag = new PropertyBag();
propertyBag.SetPropertyValue("StringProperty", "test");
propertyBag.SetPropertyValue("IntProperty", 1);
Assert.AreEqual("test", propertyBag.GetPropertyValue<string>("StringProperty"));
Assert.AreEqual(1, propertyBag.GetPropertyValue<int>("IntProperty"));
}
示例4: SetsPropertyCorrectly
public void SetsPropertyCorrectly()
{
var propertyBag = new PropertyBag();
propertyBag.SetPropertyValue("StringProperty", "A");
Assert.AreEqual("A", propertyBag.GetPropertyValue<string>("StringProperty"));
propertyBag.SetPropertyValue("StringProperty", "B");
Assert.AreEqual("B", propertyBag.GetPropertyValue<string>("StringProperty"));
}
示例5: ThrowsArgumentExceptionForInvalidPropertyName
public void ThrowsArgumentExceptionForInvalidPropertyName()
{
var propertyBag = new PropertyBag();
ExceptionTester.CallMethodAndExpectException<ArgumentException>(() => propertyBag.SetPropertyValue(null, null));
ExceptionTester.CallMethodAndExpectException<ArgumentException>(() => propertyBag.SetPropertyValue(string.Empty, null));
}