public void EqualityTest() { using var i = new ShellItem(testDoc); using var l = new ShellLink(testLinkDoc); using ShellItem lt = l.Target; Assert.That(i == lt, Is.True); Assert.That(i != lt, Is.False); Assert.That(i.Equals(lt), Is.True); Assert.That(i.CompareTo(lt), Is.Zero); Assert.That(i.CompareTo(l), Is.Not.Zero); Assert.That(((IComparable <ShellItem>)i).CompareTo(lt), Is.Zero); Assert.That(((IComparable <ShellItem>)i).CompareTo(l), Is.Not.Zero); Assert.That(i.Equals(lt.IShellItem), Is.True); Assert.That(i.Equals(lt.Name), Is.False); Assert.That(i.Equals((object)null), Is.False); Assert.That(i.Equals((IShellItem)null), Is.False); Assert.That(i.Equals((ShellItem)null), Is.False); Assert.That(i.GetHashCode(), Is.EqualTo(lt.GetHashCode())); }
/// <summary> /// Gets the item that represents the specified trace otherwise null. /// </summary> /// <param name="trace">The Trace property of the associated BreadcrumbItem.</param> /// <returns>An object included in Items, otherwise null.</returns> public object GetTraceItem(ShellItem trace) => Items.OfType <ShellItem>().FirstOrDefault(s => s != null && s.GetHashCode() == trace.GetHashCode());
/// <summary> /// Gets the item that represents the specified trace otherwise null. /// </summary> /// <param name="trace">The Trace property of the associated BreadcrumbItem.</param> /// <returns>An object included in Items, otherwise null.</returns> public object GetTraceItem(ShellItem trace) => Items.OfType<ShellItem>().FirstOrDefault(s => s != null && s.GetHashCode() == trace.GetHashCode());