public void KeyEqualsByServiceTypeAndFactoryType() { var keyOne = new ServiceKey(typeof(IFormatProvider), typeof(IFormattable)); var keyTwo = new ServiceKey(typeof(IFormatProvider), typeof(IFormattable)); Assert.AreEqual(keyOne, keyTwo); Assert.AreEqual(keyOne.GetHashCode(), keyTwo.GetHashCode()); }
public void KeyNotEqualsByDifferentFactoryTypes() { var keyOne = new ServiceKey(typeof(IFormatProvider), typeof(object)); var keyTwo = new ServiceKey(typeof(IFormatProvider), typeof(IFormattable)); Assert.AreNotEqual(keyOne, keyTwo); Assert.AreNotEqual(keyOne.GetHashCode(), keyTwo.GetHashCode()); }
public void KeyNotEqualsByDifferentServiceTypes() { var keyOne = new ServiceKey (typeof(object), typeof(IFormattable)); var keyTwo = new ServiceKey (typeof(IFormatProvider), typeof(IFormattable)); Assert.AreNotEqual (keyOne, keyTwo); Assert.AreNotEqual (keyOne.GetHashCode (), keyTwo.GetHashCode ()); }
public void KeyEqualsByServiceTypeAndFactoryType() { var keyOne = new ServiceKey (typeof(IFormatProvider), typeof(IFormattable)); var keyTwo = new ServiceKey (typeof(IFormatProvider), typeof(IFormattable)); Assert.AreEqual (keyOne, keyTwo); Assert.AreEqual (keyOne.GetHashCode (), keyTwo.GetHashCode ()); }
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 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 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> /// Serves as a hash function for a particular type. /// </summary> /// <returns> /// A hash code for the current <see cref="T:System.Object"/>. /// </returns> public override int GetHashCode() { return(ServiceKey.GetHashCode() ^ ServiceType.GetHashCode()); }