public void IndicatesIfCanUndo() { var history = new VialSetHistory(); var set = new VialSet() { Vials = new Vial[] { new Vial(new Color[] { Color.Red }), new Vial(new Color[] { Color.Green, Color.Red }), new Vial(new Color[] { Color.Green, Color.Green }), } }; history.CanUndo.ShouldBeFalse(); set.Vials.ElementAt(0).Stack(set.Vials.ElementAt(1).Pop()); history.RegisterMove(new Pouring(1, 0)); history.CanUndo.ShouldBeTrue(); set.Vials.ElementAt(1).Stack(set.Vials.ElementAt(2).Pop()); set.Vials.ElementAt(1).Stack(set.Vials.ElementAt(2).Pop()); history.RegisterMove(new Pouring(2, 1, 2)); history.CanUndo.ShouldBeTrue(); history.Undo(set); history.CanUndo.ShouldBeTrue(); history.Undo(set); history.CanUndo.ShouldBeFalse(); history.Redo(set); history.CanUndo.ShouldBeTrue(); }
public void NextCanBeFetched() { var history = new VialSetHistory(); var set = new VialSet() { Vials = new Vial[] { new Vial(new Color[] { Color.Red }), new Vial(new Color[] { Color.Green, Color.Red }), new Vial(new Color[] { Color.Green, Color.Green }), } }; set.Vials.ElementAt(0).Stack(set.Vials.ElementAt(1).Pop()); history.RegisterMove(new Pouring(1, 0)); set.Vials.ElementAt(1).Stack(set.Vials.ElementAt(2).Pop()); set.Vials.ElementAt(1).Stack(set.Vials.ElementAt(2).Pop()); history.RegisterMove(new Pouring(2, 1, 2)); set = history.Undo(set); set = history.Undo(set); set = history.Redo(set); set.ContentEquals(new VialSet() { Vials = new Vial[] { new Vial(new Color[] { Color.Red, Color.Red }), new Vial(new Color[] { Color.Green }), new Vial(new Color[] { Color.Green, Color.Green }), } }).ShouldBeTrue(); set = history.Redo(set); set.ContentEquals(new VialSet() { Vials = new Vial[] { new Vial(new Color[] { Color.Red, Color.Red }), new Vial(new Color[] { Color.Green, Color.Green, Color.Green }), new Vial(new Color[] { }), } }).ShouldBeTrue(); set = history.Redo(set); set.ContentEquals(new VialSet() { Vials = new Vial[] { new Vial(new Color[] { Color.Red, Color.Red }), new Vial(new Color[] { Color.Green, Color.Green, Color.Green }), new Vial(new Color[] { }), } }).ShouldBeTrue(); }
public void MoveWasMade(Pouring pouring) { VialSetHistory.RegisterMove(pouring); RefreshControls(); }