Exemple #1
0
        public void GetHashCodeOfNullTest()
        {
            const int expected = 0;
            var       actual   = BlobComparer.GetBlobHashCode(null);

            Assert.Equal(expected, actual);
        }
Exemple #2
0
        public void GetHashCodeOfHalfIntTest()
        {
            const short expected = 31241;
            var         actual   = BlobComparer.GetBlobHashCode(BitConverter.GetBytes(expected));

            Assert.Equal(expected, actual);
        }
Exemple #3
0
        public void GetHashCodeOfWholeIntTest()
        {
            const int expected = 402338134;
            var       actual   = BlobComparer.GetBlobHashCode(BitConverter.GetBytes(expected));

            Assert.Equal(expected, actual);
        }
        public void DeserializeBlob()
        {
            var expected = new BlobGraph {
                Value = Encoding.Unicode.GetBytes("Hello World")
            };

            _context.AssertDeserialize("{\"value\": \"SABlAGwAbABvACAAVwBvAHIAbABkAA==\"}",
                                       expected, (l, r) => BlobComparer.CompareBlobs(l.Value, r.Value));
        }
Exemple #5
0
        public void CompareRightGreaterTest()
        {
            var right = new Byte[] { 2, 1, 3 };
            var left  = new Byte[] { 1, 2, 3 };

            const int expected = -1;

            Assert.Equal(expected, BlobComparer.CompareBlobs(left, right));
        }
Exemple #6
0
        public void CompareRightIsNullTest()
        {
            var right = (byte[])null;
            var left  = new Byte[] { 1, 2, 3 };

            const int expected = 1;

            Assert.Equal(expected, BlobComparer.CompareBlobs(left, right));
        }
Exemple #7
0
        public void CompareLeftLessTest()
        {
            var left  = new Byte[] { 1, 0, 3 };
            var right = new Byte[] { 1, 2, 3 };

            const int expected = -1;

            Assert.Equal(expected, BlobComparer.CompareBlobs(left, right));
        }
Exemple #8
0
        public void CompareEqualBothNullTest()
        {
            var left  = (byte[])null;
            var right = (byte[])null;

            const int expected = 0;

            Assert.Equal(expected, BlobComparer.CompareBlobs(left, right));
        }
Exemple #9
0
        public override bool Equals(object obj)
        {
            var other = obj as Category;

            if (other == null)
            {
                return(false);
            }

            return(Name == other.Name && Description == other.Description && BlobComparer.AreEqual(Image, other.Image));
        }
Exemple #10
0
        public void GetHashCodeOfSeriesTest()
        {
            const int   part1 = 402338134;
            const int   part2 = 235436;
            const short part3 = 31241;

            var blob = new byte[10];

            Array.Copy(BitConverter.GetBytes(part1), 0, blob, 0, 4);
            Array.Copy(BitConverter.GetBytes(part2), 0, blob, 4, 4);
            Array.Copy(BitConverter.GetBytes(part3), 0, blob, 8, 2);

            var       actual   = BlobComparer.GetBlobHashCode(blob);
            const int expected = part1 ^ part2 ^ part3;

            Assert.Equal(expected, actual);
        }
Exemple #11
0
 public override int GetHashCode()
 {
     return((Name == null ? 0 : Name.GetHashCode())
            ^ (Description == null ? 0 : Description.GetHashCode())
            ^ BlobComparer.GetBlobHashCode(Image));
 }