public void Back_MoveInHistory() { var query = new[] { new Mock <IQuery>(), new Mock <IQuery>(), new Mock <IQuery>(), new Mock <IQuery>(), new Mock <IQuery>(), }; for (var i = 0; i < query.Length; ++i) { query[i].Setup(mock => mock.Text).Returns(i.ToString()); } IExecutableQuery current = null; var queryEvents = new QueryHistory(); queryEvents.QueryExecuted += (sender, args) => current = args.Query; Assert.IsNull(queryEvents.Current); queryEvents.ExecuteQuery(query[0].Object); Assert.AreEqual(query[0].Object, queryEvents.Current); Assert.AreEqual(query[0].Object, current); queryEvents.ExecuteQuery(query[1].Object); Assert.AreEqual(query[1].Object, queryEvents.Current); Assert.AreEqual(query[1].Object, current); queryEvents.Back(); Assert.AreEqual(query[0].Object, queryEvents.Current); Assert.AreEqual(query[0].Object, current); queryEvents.ExecuteQuery(query[2].Object); Assert.AreEqual(query[2].Object, queryEvents.Current); Assert.AreEqual(query[2].Object, current); queryEvents.ExecuteQuery(query[3].Object); Assert.AreEqual(query[3].Object, queryEvents.Current); Assert.AreEqual(query[3].Object, current); queryEvents.Back(); Assert.AreEqual(query[2].Object, queryEvents.Current); Assert.AreEqual(query[2].Object, current); queryEvents.Back(); Assert.AreEqual(query[0].Object, queryEvents.Current); Assert.AreEqual(query[0].Object, current); queryEvents.Back(); Assert.AreEqual(query[0].Object, queryEvents.Current); Assert.AreEqual(query[0].Object, current); queryEvents.ExecuteQuery(query[4].Object); Assert.AreEqual(query[4].Object, queryEvents.Current); Assert.AreEqual(query[4].Object, current); }
public void Back_EmptyHistory() { var executed = false; var queryEvents = new QueryHistory(); queryEvents.QueryExecuted += (sender, args) => executed = true; Assert.IsFalse(executed); Assert.IsNull(queryEvents.Current); queryEvents.Back(); Assert.IsFalse(executed); Assert.IsNull(queryEvents.Current); }