コード例 #1
0
        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));
        }
コード例 #2
0
ファイル: IdentifierTest.cs プロジェクト: sagifogel/NCop
        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));
        }
コード例 #3
0
ファイル: ServiceKeyFixture.cs プロジェクト: w0rd-driven/funq
        public void KeyNotEqualsOtherType()
        {
            var key1 = new ServiceKey(typeof(Func<IDisposable>), null);

            Assert.AreNotEqual(key1, new object());
            Assert.IsFalse(key1.Equals(new object()));
        }
コード例 #4
0
        public void KeyNotEqualsNull()
        {
            var key1 = new ServiceKey(typeof(Func <IDisposable>), null);

            Assert.AreNotEqual(key1, null);
            Assert.IsFalse(key1.Equals(null));
        }
コード例 #5
0
ファイル: ServiceKeyFixture.cs プロジェクト: w0rd-driven/funq
        public void KeyNotEqualsNull()
        {
            var key1 = new ServiceKey(typeof(Func<IDisposable>), null);

            Assert.AreNotEqual(key1, null);
            Assert.IsFalse(key1.Equals(null));
        }
コード例 #6
0
        public void KeyNotEqualsOtherType()
        {
            var key1 = new ServiceKey(typeof(Func <IDisposable>), null);

            Assert.AreNotEqual(key1, new object());
            Assert.IsFalse(key1.Equals(new object()));
        }
コード例 #7
0
        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));
        }
コード例 #8
0
ファイル: KeyedService.cs プロジェクト: Ankitvaibs/SM
        /// <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);
        }
コード例 #9
0
ファイル: ServiceKeyFixture.cs プロジェクト: w0rd-driven/funq
        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));
        }
コード例 #10
0
        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));
        }
コード例 #11
0
        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));
        }
コード例 #12
0
ファイル: ServiceKeyFixture.cs プロジェクト: w0rd-driven/funq
        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));
        }
コード例 #13
0
        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));
        }
コード例 #14
0
        /// <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));
        }