本文整理汇总了C#中Person.With方法的典型用法代码示例。如果您正苦于以下问题:C# Person.With方法的具体用法?C# Person.With怎么用?C# Person.With使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Person
的用法示例。
在下文中一共展示了Person.With方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Returns_Expected_When_Intermediate_Is_Null
public void Returns_Expected_When_Intermediate_Is_Null()
{
Person person = new Person { Address = null };
var result = person.With(x => x.Address).Return(x => x.ZipCode, "None");
Assert.AreEqual("None", result);
}
示例2: Returns_Property_Value_When_Given
public void Returns_Property_Value_When_Given()
{
Person person = new Person { Address = new Address { ZipCode = "46231" } };
var result = person.With(x => x.Address).Return(x => x.ZipCode, "None");
Assert.AreEqual("46231", result);
}
示例3: Returns_Expected_When_Final_Value_Is_Null
public void Returns_Expected_When_Final_Value_Is_Null()
{
Person person = new Person { Address = new Address { ZipCode = null } };
var result = person.With(x => x.Address).Return(x => x.ZipCode, "None");
Assert.AreEqual("None", result);
}