本文整理汇总了C#中ClassA.If方法的典型用法代码示例。如果您正苦于以下问题:C# ClassA.If方法的具体用法?C# ClassA.If怎么用?C# ClassA.If使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClassA
的用法示例。
在下文中一共展示了ClassA.If方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WhenMissingPropertyInTargetObjectThenExceptionIsRaised
public void WhenMissingPropertyInTargetObjectThenExceptionIsRaised()
{
var classA = new ClassA(null, "Test");
var classAMissingProp = new ClassAWithMissingProp("Test");
Assert.Throws<MissingMemberException>(() =>
{
classA.If().PropertyValuesMatch(classAMissingProp).ThenReturn(true);
});
}
示例2: WhenAllPropertiesMatchThenPositiveIsReturned
public void WhenAllPropertiesMatchThenPositiveIsReturned() {
var classA = new ClassA(null, "Test");
var classB = new ClassB(null, "Test");
Assert.True(classA.If().PropertyValuesMatch(classB).ThenReturn(true));
Assert.False(classA.If().PropertyValuesDoNotMatch(classB).ThenReturn(true));
}
示例3: WhenPropertyInTargetObjectHasWrongTypeThenExceptionIsRaised
public void WhenPropertyInTargetObjectHasWrongTypeThenExceptionIsRaised()
{
var classA = new ClassA(1, "Test");
var classAWithWrongPropType = new ClassAWithWrongPropType(1, "Test");
Assert.Throws<InvalidCastException>(() =>
{
classA.If().PropertyValuesMatch(classAWithWrongPropType).ThenReturn(true);
});
}
示例4: WhenCollectionDoesNotContainItemExceptionIsThrownOtherwiseNot
public void WhenCollectionDoesNotContainItemExceptionIsThrownOtherwiseNot()
{
var item = new ClassA(1, "Test");
var item2 = new ClassA(2, "Test2");
var list = new List<ClassA>();
list.Add(item);
var ex = Assert.Throws<ArgumentException>(() =>
{
item2.If().IsNotPartOf(list).ThenThrow<ArgumentException>();
});
item.If().IsNotPartOf(list).ThenThrow<ArgumentException>();
}
示例5: WhenPropertyDiffIsIgnoredThenPositiveResultIsReturned
public void WhenPropertyDiffIsIgnoredThenPositiveResultIsReturned() {
var classA = new ClassA(1, "Test");
var classB = new ClassB(2, "Test");
Assert.False(classA.If().PropertyValuesDoNotMatch(classB, (prop, expected, actual) =>
{
return false;
}).ThenReturn(true));
}
示例6: WhenNotAllPropertiesMatchThenNegativeIsReturned
public void WhenNotAllPropertiesMatchThenNegativeIsReturned() {
var classA = new ClassA(1, "Test");
var classB = new ClassB(2, "Test");
var match = classA.If().PropertyValuesMatch(classB).ThenReturn(true);
Assert.False(match);
match = classA.If().PropertyValuesDoNotMatch(classB).ThenReturn(true);
Assert.True(match);
}