public void Delete() { var sut = new MealItemEditingViewModel(); var needToDelete = false; sut.StateProvider = stateProvider; sut.NeedToDelete += delegate { needToDelete = true; }; sut.ChangesProperty("IsVisible", () => sut.Delete.Call()); Assert.IsTrue(needToDelete); Assert.IsFalse(sut.IsVisible); Assert.IsFalse(stateProvider.State.ContainsKey(MealItemEditingViewModel.MEAL_ITEM)); }
public void Confirm() { var sut = new MealItemEditingViewModel(); var confirmed = false; sut.StateProvider = stateProvider; sut.Confirmed += delegate { confirmed = true; }; sut.ChangesProperty("IsVisible", () => sut.Confirm.Call()); Assert.IsTrue(confirmed); Assert.IsFalse(sut.IsVisible); Assert.IsFalse(stateProvider.State.ContainsKey(MealItemEditingViewModel.MEAL_ITEM)); }
public void Show() { var sut = new MealItemEditingViewModel(); var model = new MealItem { Value = 5 }; var mealItem = new MealItemViewModel(model, Substitute.For<Factories>()); var needToShow = false; stateProvider.State[MealItemEditingViewModel.MEAL_ITEM] = model.Serialize(string.Empty); model.Value = 1; sut.StateProvider = stateProvider; sut.NeedToShow += delegate { needToShow = true; }; sut.ChangesProperty("IsVisible", () => sut.Show(mealItem)); Assert.AreEqual("5", sut.Subject.Value); Assert.IsTrue(needToShow); Assert.IsTrue(sut.IsVisible); }