Example #1
0
        public void Equality_String()
        {
            Id s1  = new StringId("1");
            Id s11 = new StringId("1");
            Id s2  = new StringId("2");

            // String
            Assert.IsTrue(s1.Equals(s11));
            Assert.IsTrue(s11.Equals(s1));
            Assert.IsFalse(s1.Equals(s2));
            Assert.IsFalse(s2.Equals(s1));
            Assert.IsFalse(s2.Equals(null));

            Assert.IsTrue(s1 == s11);
            Assert.IsTrue(s11 == s1);
            Assert.IsFalse(s1 == s2);
            Assert.IsFalse(s2 == s1);
        }
Example #2
0
        public void StringTable_can_store_one_element()
        {
            StringTable stringTable = new StringTable();

            StringTable.CachingBuilder builder = new StringTable.CachingBuilder(stringTable);

            StringId id  = builder.GetOrAdd("a");
            StringId id2 = builder.GetOrAdd("a");

            XAssert.IsTrue(id.Equals(id2));
            XAssert.IsFalse(id.Equals(default));
Example #3
0
        public Boolean Equals(ResourceIdentifier other)
        {
            if (Object.ReferenceEquals(this, other))
            {
                return(true);
            }
            if (Object.ReferenceEquals(other, null))
            {
                return(false);
            }

            if (IntegerId != null && (IntegerId == other.IntegerId))
            {
                return(true);
            }

            if (IntegerId == null && (other.IntegerId == null))
            {
                return(StringId.Equals(other.StringId));
            }

            return(false);
        }
Example #4
0
        public bool Equals(ResourceIdentifier other)
        {
            if (ReferenceEquals(this, other))
            {
                return(true);
            }
            if (ReferenceEquals(other, null))
            {
                return(false);
            }

            if (IntegerId != null && IntegerId == other.IntegerId)
            {
                return(true);
            }

            if (IntegerId == null && other.IntegerId == null)
            {
                return(StringId.Equals(other.StringId));
            }

            return(false);
        }