Ejemplo n.º 1
0
        /// <summary>
        /// Gets the hash code.
        /// </summary>
        /// <returns>The hash code.</returns>
        public override int GetHashCode()
        {
            // see Effective Java by Joshua Bloch
            int hash = 17;

            hash = 37 * hash + base.GetHashCode();
            hash = 37 * hash + _scope.GetHashCode();
            return(hash);
        }
        public void TestGetHashcode()
        {
            var bsonDocument = new BsonDocument {
                { "x", 1 }, { "y", 2 }
            };
            var bson = bsonDocument.ToBson();

            using (var rawBsonDocument = BsonSerializer.Deserialize <RawBsonDocument>(bson))
            {
                Assert.Equal(bsonDocument.GetHashCode(), rawBsonDocument.GetHashCode());
            }
        }
 public void TestBsonDocumentEquals() {
     BsonDocument lhs = new BsonDocument {
         { "Hello", "World" },
         { "Foo", "Bar" }
     };
     BsonDocument rhs = new BsonDocument(
         new BsonElement("Hello", "World"),
         new BsonElement("Foo", "Bar")
     );
     Assert.AreNotSame(lhs, rhs);
     Assert.AreEqual(lhs, rhs);
     Assert.AreEqual(lhs.GetHashCode(), rhs.GetHashCode());
 }
Ejemplo n.º 4
0
        public void TestBsonDocumentEquals()
        {
            BsonDocument lhs = new BsonDocument {
                { "Hello", "World" },
                { "Foo", "Bar" }
            };
            BsonDocument rhs = new BsonDocument(
                new BsonElement("Hello", "World"),
                new BsonElement("Foo", "Bar")
                );

            Assert.AreNotSame(lhs, rhs);
            Assert.AreEqual(lhs, rhs);
            Assert.AreEqual(lhs.GetHashCode(), rhs.GetHashCode());
        }
        /// <summary>
        /// Returns the hash code for this MongoGridFSFileInfo object.
        /// </summary>
        /// <returns>A 32-bit signed integer hash code.</returns>
        public override int GetHashCode()
        {
            // see Effective Java by Joshua Bloch
            int hash = 17;

            hash = 37 * hash + ((_aliases == null) ? 0 : _aliases.GetHashCode());
            hash = 37 * hash + _chunkSize.GetHashCode();
            hash = 37 * hash + ((_contentType == null) ? 0 : _contentType.GetHashCode());
            hash = 37 * hash + ((_id == null) ? 0 : _id.GetHashCode());
            hash = 37 * hash + _length.GetHashCode();
            hash = 37 * hash + ((_md5 == null) ? 0 : _md5.GetHashCode());
            hash = 37 * hash + ((_metadata == null) ? 0 : _metadata.GetHashCode());
            hash = 37 * hash + ((_name == null) ? 0 : _name.GetHashCode());
            hash = 37 * hash + _uploadDate.GetHashCode();
            return(hash);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Gets the hash code.
        /// </summary>
        /// <returns>The hash code.</returns>
        public override int GetHashCode()
        {
            // see Effective Java by Joshua Bloch
            int hash = 17;

            hash = 37 * hash + ((aliases == null) ? 0 : aliases.GetHashCode());
            hash = 37 * hash + chunkSize.GetHashCode();
            hash = 37 * hash + ((contentType == null) ? 0 : contentType.GetHashCode());
            hash = 37 * hash + ((id == null) ? 0 : id.GetHashCode());
            hash = 37 * hash + length.GetHashCode();
            hash = 37 * hash + ((md5 == null) ? 0 : md5.GetHashCode());
            hash = 37 * hash + ((metadata == null) ? 0 : metadata.GetHashCode());
            hash = 37 * hash + name.GetHashCode();
            hash = 37 * hash + uploadDate.GetHashCode();
            return(hash);
        }
Ejemplo n.º 7
0
 /// <inheritdoc/>
 public override int GetHashCode()
 {
     return(_wrapped.GetHashCode());
 }
Ejemplo n.º 8
0
 public void TestGetHashcode()
 {
     var bsonDocument = new BsonDocument { { "x", 1 }, { "y", 2 } };
     var bson = bsonDocument.ToBson();
     using (var rawBsonDocument = BsonSerializer.Deserialize<RawBsonDocument>(bson))
     {
         Assert.Equal(bsonDocument.GetHashCode(), rawBsonDocument.GetHashCode());
     }
 }
 public void TestGetHashCode()
 {
     var document = new BsonDocument("x", 1);
     var hashCode = document.GetHashCode();
     Assert.AreEqual(hashCode, document.GetHashCode()); // returns same value when called again
 }
Ejemplo n.º 10
0
 public override int GetHashCode()
 {
     return(_document.GetHashCode());
 }
Ejemplo n.º 11
0
        public void TryConvert_CastToBsonDocument()
        {
            // Dson holds a reference to Bson.
            var bsonDoc = new BsonDocument("a", 1);
            var dson = Dson.New(bsonDoc);

            BsonDocument bsonDoc1 = dson;
            var bsonDoc2 = dson.AsBsonDocument;
            var bsonDoc3 = (BsonDocument)dson.AsBsonDocument;

            Assert.AreEqual(bsonDoc.GetHashCode(), bsonDoc1.GetHashCode());
            Assert.AreEqual(bsonDoc.GetHashCode(), bsonDoc2.GetHashCode());
            Assert.AreEqual(bsonDoc.GetHashCode(), bsonDoc3.GetHashCode());
        }