Created
August 3, 2016 11:14
Revisions
-
darrencauthon created this gist
Aug 3, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,55 @@ void Main() { It_should_return_the_name_from_the_person_on_the_invoice_on_the_order(); It_should_return_nothing_if_the_person_is_not_set(); It_should_return_nothing_if_the_invoice_is_not_set(); It_should_return_nothing_if_given_nothing(); } public static string GetNameFrom(Order order) { return order?.Invoice?.Person?.Name; } public static void It_should_return_the_name_from_the_person_on_the_invoice_on_the_order() { var name = Guid.NewGuid().ToString(); var order = new Order { Invoice = new Invoice { Person = new Person { Name = name } } }; GetNameFrom(order).ShouldEqual(name); } public static void It_should_return_nothing_if_the_person_is_not_set() { var order = new Order { Invoice = new Invoice { Person = null } }; GetNameFrom(order).ShouldBeNull(); } public void It_should_return_nothing_if_the_invoice_is_not_set() { var order = new Order { Invoice = null }; GetNameFrom(order).ShouldBeNull(); } public void It_should_return_nothing_if_given_nothing() { Order order = null; GetNameFrom(order).ShouldBeNull(); } public class Order { public Invoice Invoice { get; set; } } public class Invoice { public Person Person { get; set; } } public class Person { public string Name { get; set; } }