Пример #1
0
        public void TestSameInstanceEquality()
        {
            FindsByAttribute first = new FindsByAttribute()
            {
                How = How.Id, Using = "Test"
            };
            FindsByAttribute second = first;

            Assert.That(first == second, Is.True);
            Assert.That(second == first, Is.True);
            Assert.That(first.Equals(second), Is.True);
            Assert.That(second.Equals(first), Is.True);
            Assert.That(object.ReferenceEquals(first, second), Is.True);
        }
Пример #2
0
        public void TestInequalityOfPriority()
        {
            FindsByAttribute first = new FindsByAttribute()
            {
                How = How.Id, Using = "Test", Priority = 1
            };
            FindsByAttribute second = new FindsByAttribute()
            {
                How = How.Id, Using = "Test", Priority = 2
            };

            Assert.That(first.Equals(second), Is.False);
            Assert.That(first == second, Is.False);
            Assert.That(first != second, Is.True);
        }
Пример #3
0
        public void TestInequalityOfUsing()
        {
            FindsByAttribute first = new FindsByAttribute()
            {
                How = How.Id, Using = "Hello"
            };
            FindsByAttribute second = new FindsByAttribute()
            {
                How = How.Id, Using = "World"
            };

            Assert.That(first.Equals(second), Is.False);
            Assert.That(first == second, Is.False);
            Assert.That(first != second, Is.True);
        }
Пример #4
0
        public void TestInequalityOfHow()
        {
            FindsByAttribute first = new FindsByAttribute()
            {
                How = How.Name, Using = "Test"
            };
            FindsByAttribute second = new FindsByAttribute()
            {
                How = How.Id, Using = "Test"
            };

            Assert.IsFalse(first.Equals(second));
            Assert.IsFalse(first == second);
            Assert.IsTrue(first != second);
        }
Пример #5
0
        public void TestInequalityOfNull()
        {
            FindsByAttribute first = new FindsByAttribute()
            {
                How = How.Id, Using = "Test"
            };
            FindsByAttribute second = null;

            Assert.That(first.Equals(second), Is.False);

            // Must test order of arguments for overridden operators
            Assert.That(first == second, Is.False);
            Assert.That(first != second, Is.True);
            Assert.That(second == first, Is.False);
            Assert.That(second != first, Is.True);
        }
Пример #6
0
        public void TestEquality()
        {
            FindsByAttribute first = new FindsByAttribute()
            {
                How = How.Id, Using = "Test"
            };
            FindsByAttribute second = new FindsByAttribute()
            {
                How = How.Id, Using = "Test"
            };

            Assert.IsTrue(first.Equals(second));
            Assert.IsFalse(object.ReferenceEquals(first, second));
            Assert.IsTrue(first == second);
            Assert.IsFalse(first != second);
        }