Esempio n. 1
0
        public void EqualsFalseNullOtherPayload()
        {
            var v1 = new ContentHashList(ContentHashArray, new byte[] { 0 });
            var v2 = new ContentHashList(ContentHashArray);

            Assert.False(v1.Equals(v2));
        }
Esempio n. 2
0
        public void EqualsFalseMismatchPayload()
        {
            var v1 = new ContentHashList(ContentHashArray, new byte[] { 0, 1 });
            var v2 = new ContentHashList(ContentHashArray, new byte[] { 0 });

            Assert.False(v1.Equals(v2));
        }
Esempio n. 3
0
        public void EqualsObjectFalse()
        {
            var v1 = new ContentHashList(ContentHashArray);
            var v2 = new object();

            Assert.False(v1.Equals(v2));
        }
Esempio n. 4
0
        public void EqualsObjectTrue()
        {
            var v1 = new ContentHashList(ContentHashArray);
            var v2 = new ContentHashList(ContentHashArray) as object;

            Assert.True(v1.Equals(v2));
        }
Esempio n. 5
0
        public void EqualsFalseWithPayload()
        {
            var v1 = new ContentHashList(ContentHashArray, new byte[] { 1, 2, 3 });
            var v2 = new ContentHashList(ContentHashArray, new byte[] { 1, 1, 3 });

            Assert.False(v1.Equals(v2));
        }
Esempio n. 6
0
        public void EqualsTrueNotReferenceEqualContentHashArray()
        {
            var b  = Enumerable.Repeat((byte)0, 20).ToArray();
            var v1 = new ContentHashList(new[] { new ContentHash(HashType.SHA1, b) });
            var v2 = new ContentHashList(new[] { new ContentHash(HashType.SHA1, b) }) as object;

            Assert.True(v1.Equals(v2));
        }
        /// <summary>
        ///     Determine the ContentHashList to return based on the added value and the service response.
        /// </summary>
        protected static ContentHashList UnpackContentHashListAfterAdd(
            ContentHashList addedContentHashList, ContentHashListWithCacheMetadata cacheMetadata)
        {
            Contract.Assert(cacheMetadata != null);

            if (cacheMetadata.ContentHashListWithDeterminism.ContentHashList != null &&
                !addedContentHashList.Equals(
                    cacheMetadata.ContentHashListWithDeterminism.ContentHashList))
            {
                // The service returned a ContentHashList different from the one we tried to add, so we'll return that.
                return(cacheMetadata.ContentHashListWithDeterminism.ContentHashList);
            }

            // The added value was accepted, so we return null.
            return(null);
        }