public void DifferentTypesInIdentifier_ReturnsNotSameObject() { var identifier1 = new ServiceKey(typeof(Action), typeof(Action), "first"); var identifier2 = new ServiceKey(typeof(Delegate), typeof(Action), "first"); var identifier3 = new ServiceKey(typeof(Action), typeof(Action), "second"); var identifier4 = new ServiceKey(typeof(Delegate), typeof(Action), "second"); Assert.IsTrue(!identifier1.Equals(identifier2) && !identifier1.Equals(identifier3) && !identifier1.Equals(identifier4) && !identifier2.Equals(identifier3) && !identifier2.Equals(identifier4) && !identifier3.Equals(identifier4)); }
public void DifferentTypesInIdentifier_ReturnsNotSameObject() { var identifier1 = new ServiceKey(typeof(Action), typeof(Action), "first"); var identifier2 = new ServiceKey(typeof(Delegate), typeof(Action), "first"); var identifier3 = new ServiceKey(typeof(Action), typeof(Action), "second"); var identifier4 = new ServiceKey(typeof(Delegate), typeof(Action), "second"); Assert.IsTrue(!identifier1.Equals(identifier2) && !identifier1.Equals(identifier3) && !identifier1.Equals(identifier4) && !identifier2.Equals(identifier3) && !identifier2.Equals(identifier4) && !identifier3.Equals(identifier4)); }
public void KeyNotEqualsOtherType() { var key1 = new ServiceKey(typeof(Func<IDisposable>), null); Assert.AreNotEqual(key1, new object()); Assert.IsFalse(key1.Equals(new object())); }
public void KeyNotEqualsNull() { var key1 = new ServiceKey(typeof(Func <IDisposable>), null); Assert.AreNotEqual(key1, null); Assert.IsFalse(key1.Equals(null)); }
public void KeyNotEqualsNull() { var key1 = new ServiceKey(typeof(Func<IDisposable>), null); Assert.AreNotEqual(key1, null); Assert.IsFalse(key1.Equals(null)); }
public void KeyNotEqualsOtherType() { var key1 = new ServiceKey(typeof(Func <IDisposable>), null); Assert.AreNotEqual(key1, new object()); Assert.IsFalse(key1.Equals(new object())); }
public void Func_Container_Hash_provider_is_Equal() { var source = new ServiceKey(typeof(Func <Container, IHashProvider>), string.Empty); var other = new ServiceKey(typeof(Func <Container, IHashProvider>), string.Empty); Assert.IsTrue(source.Equals(other)); Assert.That(source, Is.EqualTo(other)); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns> /// true if the current object is equal to the <paramref name="other" /> parameter; otherwise, false. /// </returns> public bool Equals(KeyedService other) { if (other == null) { return(false); } return(ServiceKey.Equals(other.ServiceKey) && ServiceType == other.ServiceType); }
public void KeyEqualsSameReference() { var key1 = new ServiceKey(typeof(Func<IDisposable>), null); var key2 = key1; Assert.AreSame(key1, key2); Assert.IsTrue(ServiceKey.Equals(key1, key2)); Assert.IsTrue(key1.Equals(key2)); }
public void KeysNotEqualByName() { var key1 = new ServiceKey(typeof(Func <IDisposable>), "foo"); var key2 = new ServiceKey(typeof(Func <IDisposable>), "bar"); Assert.AreNotEqual(key1, key2); Assert.AreNotEqual(key1.GetHashCode(), key2.GetHashCode()); Assert.IsFalse(ServiceKey.Equals(key1, key2)); }
public void KeyEqualsSameReference() { var key1 = new ServiceKey(typeof(Func <IDisposable>), null); var key2 = key1; Assert.AreSame(key1, key2); Assert.IsTrue(ServiceKey.Equals(key1, key2)); Assert.IsTrue(key1.Equals(key2)); }
public void KeysAreEqualByTypeAndName() { var key1 = new ServiceKey(typeof(Func<IDisposable>), "foo"); var key2 = new ServiceKey(typeof(Func<IDisposable>), "foo"); Assert.AreEqual(key1, key2); Assert.AreEqual(key1.GetHashCode(), key2.GetHashCode()); Assert.IsTrue(ServiceKey.Equals(key1, key2)); Assert.IsTrue(key1.Equals(key2)); }
public void KeysAreEqualByTypeAndName() { var key1 = new ServiceKey(typeof(Func <IDisposable>), "foo"); var key2 = new ServiceKey(typeof(Func <IDisposable>), "foo"); Assert.AreEqual(key1, key2); Assert.AreEqual(key1.GetHashCode(), key2.GetHashCode()); Assert.IsTrue(ServiceKey.Equals(key1, key2)); Assert.IsTrue(key1.Equals(key2)); }
/// <summary> /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>. /// </summary> /// <param name="obj">The <see cref="T:System.Object"/> to compare with the current <see cref="T:System.Object"/>.</param> /// <returns> /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false. /// </returns> /// <exception cref="T:System.NullReferenceException">The <paramref name="obj"/> parameter is null.</exception> public override bool Equals(object obj) { var that = obj as KeyedService; if (that == null) { return(false); } return(ServiceKey.Equals(that.ServiceKey) && ServiceType.IsCompatibleWith(that.ServiceType)); }