/// <summary> /// A navigation point must take responsibility for evaluating equality tests. /// </summary> public void EqualityTest() { Assert.IsTrue(p1.Equals(p1)); Assert.IsFalse(p1.Equals(p2)); Assert.IsFalse(p1.Equals("not an INavigationPoint...")); Assert.AreNotEqual(p1.GetHashCode(), p2.GetHashCode()); }
/// <summary> /// The <see cref="NavigationService"/> must /// support multiple successive requests to /// log equivalent points, where equivalency /// is measured by INavigationPoint.Equals(), /// in which case the new point replaces the /// current point. /// </summary> public void LogMultipleEquivalentSuccessiveTest() { Assert.AreEqual(0, NavigationService.Count); Assert.IsTrue(p_5.Equals(p_6)); NavigationService.Log(p_5); NavigationService.Log(p_5); Assert.AreEqual(1, NavigationService.Count); Assert.AreEqual(p_5, NavigationService.CurrentPosition); NavigationService.Log(p_6); Assert.AreEqual(1, NavigationService.Count); Assert.AreEqual(p_6, NavigationService.CurrentPosition); }
/// <summary> /// Adds an <see cref="INavigationPoint"/> to the history. /// </summary> /// <param name="p">The <see cref="INavigationPoint"/> to add.</param> /// <remarks> /// Refactoring this out of Log() allows the NavigationService /// to call this and ensure it will work regardless of the /// requested state of loggingSuspended, as in /// <see cref="ClearHistory()"/> where we want to log /// the current position after clearing the /// history. /// </remarks> private static void LogInternal(INavigationPoint p) { if (p == null || String.IsNullOrEmpty(p.FileName) ) { return; } if (currentNode == null) { currentNode = history.AddFirst(p); } else if (p.Equals(currentNode.Value)) { // replace it currentNode.Value = p; } else { currentNode = history.AddAfter(currentNode, p); } OnHistoryChanged(); }
// refactoring this out of Log() allows the NavigationService // to call this and ensure it will work regardless of the // requested state of loggingSuspended private static void LogInternal(INavigationPoint p) { if (p == null || p.FileName == null || // HACK: why/how do we get here? p.FileName == String.Empty) // HACK: why/how do we get here? { return; } if (currentNode == null) { currentNode = history.AddFirst(p); } else if (p.Equals(currentNode.Value)) { // replace it currentNode.Value = p; } else { currentNode = history.AddAfter(currentNode, p); } OnHistoryChanged(); }
/// <summary> /// Adds an <see cref="INavigationPoint"/> to the history. /// </summary> /// <param name="p">The <see cref="INavigationPoint"/> to add.</param> /// <remarks> /// Refactoring this out of Log() allows the NavigationService /// to call this and ensure it will work regardless of the /// requested state of loggingSuspended, as in /// <see cref="ClearHistory()"/> where we want to log /// the current position after clearing the /// history. /// </remarks> private static void LogInternal(INavigationPoint p) { if (p == null || String.IsNullOrEmpty(p.FileName) ) { return; } if (currentNode==null) { currentNode = history.AddFirst(p); } else if (p.Equals(currentNode.Value)) { // replace it currentNode.Value = p; } else { currentNode = history.AddAfter(currentNode, p); } OnHistoryChanged(); }
// refactoring this out of Log() allows the NavigationService // to call this and ensure it will work regardless of the // requested state of loggingSuspended private static void LogInternal(INavigationPoint p) { if (p == null || p.FileName==null // HACK: why/how do we get here? || p.FileName==String.Empty) { // HACK: why/how do we get here? return; } if (currentNode==null) { currentNode = history.AddFirst(p); } else if (p.Equals(currentNode.Value)) { // replace it currentNode.Value = p; } else { currentNode = history.AddAfter(currentNode, p); } OnHistoryChanged(); }