public void BuildViewModelUnknownType() { var f = new FakeContactDetail(); var fvm = ContactDetailViewModel.BuildViewModel(f); Assert.IsNull(fvm, "BuildViewModel should return null when it doesn't know how to handle a type."); }
public void BuildViewModel() { Phone p = new Phone(); Email e = new Email(); Address a = new Address(); var pvm = ContactDetailViewModel.BuildViewModel(p); Assert.IsInstanceOfType(pvm, typeof(PhoneViewModel), "Factory method created wrong ViewModel type."); Assert.AreEqual(p, pvm.Model, "Underlying model object on ViewModel is not correct."); var evm = ContactDetailViewModel.BuildViewModel(e); Assert.IsInstanceOfType(evm, typeof(EmailViewModel), "Factory method created wrong ViewModel type."); Assert.AreEqual(e, evm.Model, "Underlying model object on ViewModel is not correct."); var avm = ContactDetailViewModel.BuildViewModel(a); Assert.IsInstanceOfType(avm, typeof(AddressViewModel), "Factory method created wrong ViewModel type."); Assert.AreEqual(a, avm.Model, "Underlying model object on ViewModel is not correct."); }
public void CheckNullArgumentExceptions() { Utilities.CheckNullArgumentException(() => { ContactDetailViewModel.BuildViewModel(null); }, "detail", "BuildViewModel"); }