public void GetViewForUsingViewFactoryTest() { var viewModel1 = new Example1ViewModel(); var expectedView = new Example1View(); bool factoryCalled = false; object viewFactory(Type type) { factoryCalled = true; Assert.AreEqual(typeof(Example1View), type); return(expectedView); } var view1 = _viewManager.GetViewFor(viewModel1); Assert.NotNull(view1); Assert.False(factoryCalled); Assert.AreEqual(expectedView.GetType(), view1.GetType()); _viewManager.ViewFactory = viewFactory; var viewModel2 = new Example1ViewModel(); var view2 = _viewManager.GetViewFor(viewModel1); Assert.AreSame(expectedView, view2); Assert.True(factoryCalled); }
public void GetViewForTest() { var viewModel = new Example1ViewModel(); var expectedViewType = new Example1View(); var view = _viewManager.GetViewFor(viewModel); Assert.NotNull(view); Assert.AreEqual(expectedViewType.GetType(), view.GetType()); Assert.AreSame(viewModel, view.DataContext); }