public void OnNavigatedFrom_With_RestorableStateAttributes() { var vm = new MockViewModelWithRestorableStateAttributes() { Title = "MyMock", Description = "MyDescription", EntityId = "MyEntityId" }; var result = new Dictionary<string, object>(); vm.OnNavigatedFrom(result, true); Assert.IsTrue(result.Keys.Count == 1); Assert.IsTrue(result.ContainsKey("MyEntityId")); Assert.IsNotNull(result["MyEntityId"]); Assert.IsInstanceOfType(result["MyEntityId"], typeof(Dictionary<string, object>)); var viewState = (Dictionary<string, object>)result["MyEntityId"]; Assert.IsTrue(viewState.Keys.Count == 2); Assert.IsTrue(viewState["Title"].ToString() == "MyMock"); Assert.IsTrue(viewState["Description"].ToString() == "MyDescription"); }
public void OnNavigatedTo_With_RestorableStateAttribute() { var viewModelState = new Dictionary<string, object>(); viewModelState.Add("Title", "MyMock"); viewModelState.Add("Description", "MyDescription"); var viewState = new Dictionary<string, object>(); viewState.Add("MyEntityId", viewModelState); var vm = new MockViewModelWithRestorableStateAttributes() { EntityId = "MyEntityId" }; vm.OnNavigatedTo(null, NavigationMode.Back, viewState); Assert.AreEqual(vm.Title, viewModelState["Title"]); Assert.AreEqual(vm.Description, viewModelState["Description"]); }