예제 #1
0
        public void TestDecode()
        {
            string hex = "4a7067c30a57000000008ecb";
            Oid oid = new Oid(hex);

            Assert.AreEqual("\"" + hex + "\"", oid.ToString());
        }
예제 #2
0
        public void TestDecode()
        {
            string hex = "4a7067c30a57000000008ecb";
            Oid oid = new Oid(hex);

            Assert.AreEqual(hex,"ObjectId(\"" + oid.ToString() + "\")");
        }
예제 #3
0
 public void TestDate()
 {
     string hex = "4B458B95D114BE541B000000";
     Oid oid = new Oid(hex);
     //Expected: 2010-01-07 02:24:56.633
     DateTime expected = new DateTime(2010,1,7,7,21,57,DateTimeKind.Utc);
     Assert.AreEqual(expected,oid.Created);
 }
예제 #4
0
        public void TestNewOidFromToString()
        {
            var hex = "4B458B95D114BE541B000000";
            var firstOid = new Oid(hex);
            var secondOid = new Oid(firstOid.ToString());

            Assert.AreEqual(firstOid.ToString(), secondOid.ToString());
        }
예제 #5
0
        public void TestFollowNonReference()
        {
            Oid id = new Oid("BAD067c30a57000000008ecb");
            DBRef rf = new DBRef("refs", id);

            Document target = DB.FollowReference(rf);
            Assert.IsNull(target, "FollowReference returned wasn't null");
        }
예제 #6
0
 public void CompareToTest1()
 {
     Oid target = new Oid(); // TODO: Initialize to an appropriate value
     Oid rhs = null; // TODO: Initialize to an appropriate value
     int expected = 0; // TODO: Initialize to an appropriate value
     int actual;
     actual = target.CompareTo(rhs);
     actual.Should().Be(expected);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
예제 #7
0
        public void TestFollowReference()
        {
            Database tests = mongo["tests"];
            Oid id = new Oid("4a7067c30a57000000008ecb");
            DBRef rf = new DBRef("reads", id);

            Document target = tests.FollowReference(rf);
            Assert.IsNotNull(target, "FollowReference returned null");
            Assert.IsTrue(target.Contains("j"));
            Assert.AreEqual((double)9980, (double)target["j"]);
        }
        public void DeletePost(string Id)
        {
            ConnectToDatabase();

            Oid id = new Oid(Id);

            var qry = new Document { { "_id", id } };

            collection.Delete(qry);

            DisconnectFromDatabase();

            return;
        }
예제 #9
0
        public void TestFollowReference()
        {
            IMongoCollection refs = DB["refs"];
            Oid id = new Oid("4a7067c30a57000000008ecb");
            string msg = "this has an oid key";
            Document doc = new Document(){{"_id", id},{"msg", msg}};
            refs.Insert(doc);

            DBRef rf = new DBRef("refs", id);

            Document target = DB.FollowReference(rf);
            Assert.IsNotNull(target, "FollowReference returned null");
            Assert.IsTrue(target.Contains("msg"));
            Assert.AreEqual(msg, target["msg"]);
        }
예제 #10
0
        public BsonOid(Oid oid)
        {
            //have to do some conversion here.
            string oidstr = oid.Value;
            if(oidstr.Length % 2 == 1){
                oidstr = "0" + oidstr;
            }
            int numberChars = oidstr.Length;

            byte[] bytes = new byte[numberChars / 2];
            for (int i = 0; i < numberChars; i += 2){
                try{
                    bytes[i / 2] = Convert.ToByte(oidstr.Substring(i, 2), 16);
                }
                catch{
                    //failed to convert these 2 chars, they may contain illegal charracters
                    bytes[i / 2] = 0;
                }
            }
            this.Val = bytes;
        }
예제 #11
0
 public void TestMongoDBRoundtrip()
 {
     Oid a = Oid.NewOid();
     string val = a.ToMongoDBString();
     string val2 = a.ToString("m", null);
     val.Should().Be(val2);
     Oid b = new Oid(val, "m");
     b.Should().Be(a);
 }
예제 #12
0
 public void TestHexadecimalRoundtrip()
 {
     Oid a = Oid.NewOid();
     string val = a.ToHexadecimalString();
     string val2 = a.ToString("h", null);
     val.Should().Be(val2);
     Oid b = new Oid(val, "h");
     Oid c = new Oid(val);
     b.Should().Be(a);
     b.Should().Be(c);
 }
예제 #13
0
 public void TestBase64Roundtrip()
 {
     Oid a = Oid.NewOid();
     string val = a.ToBase64String();
     string val2 = a.ToString("b", null);
     val.Should().Be(val2);
     Oid b = new Oid(val, "b");
     b.Should().Be(a);
 }
예제 #14
0
 public void OidConstructorTest5()
 {
     SerializationInfo serializationInfo = null; // TODO: Initialize to an appropriate value
     StreamingContext streamingContext = new StreamingContext(); // TODO: Initialize to an appropriate value
     Oid target = new Oid(serializationInfo, streamingContext);
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
예제 #15
0
 public void OidConstructorTest3()
 {
     Oid a = Oid.NewOid();
     Oid b = new Oid(a);
     a.Should().Be(b);
 }
예제 #16
0
        public void TestToByteArray()
        {
            byte[] bytes = new byte[]{1,2,3,4,5,6,7,8,9,10,11,12};
            string hex = "0102030405060708090a0b0c";

            Oid bval = new Oid(bytes);
            byte[] bytes2 = bval.ToByteArray();

            Assert.IsNotNull(bytes2);
            Assert.AreEqual(12, bytes2.Length);
            Assert.AreEqual(bytes, bytes2);
        }
예제 #17
0
 public BsonOid(Oid oid)
 {
     this.val = oid.Value;
 }
예제 #18
0
 public void GetObjectDataTest()
 {
     Oid target = new Oid(); // TODO: Initialize to an appropriate value
     SerializationInfo info = null; // TODO: Initialize to an appropriate value
     StreamingContext context = new StreamingContext(); // TODO: Initialize to an appropriate value
     target.GetObjectData(info, context);
     Assert.Inconclusive("A method that does not return a value cannot be verified.");
 }
예제 #19
0
 void element_oid(string name, Oid oid)
 {
     element_type(TypeByte.OID);
     element_name(name);
     base.Write(oid.Buffer);
 }
예제 #20
0
 public DBRef(string collectionName, Oid id)
 {
     this.CollectionName = collectionName;
     this.Id = id.Value;
 }
예제 #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Document"/> class.
 /// </summary>
 /// <remarks>
 /// For testing/internal use only...by specifying the Oid and partial flag, you are simulating the arrival of the document from a server
 /// </remarks>
 /// <param name="id">an explicitly set ID.</param>
 /// <param name="partial">if set to <c>true</c> the document represents a subset of all available fields.</param>
 public Document(Oid id, bool partial)
 {
     ID = id;
     State = DocumentState.Added | DocumentState.Unchanged;
     Partial = partial;
 }
예제 #22
0
 public void EqualsTest()
 {
     Oid target = new Oid(); // TODO: Initialize to an appropriate value
     Oid other = null; // TODO: Initialize to an appropriate value
     bool expected = false; // TODO: Initialize to an appropriate value
     bool actual;
     actual = target.Equals(other);
     actual.Should().Be(expected);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
예제 #23
0
 public void OidConstructorTest1()
 {
     string value = string.Empty; // TODO: Initialize to an appropriate value
     string format = string.Empty; // TODO: Initialize to an appropriate value
     Oid target = new Oid(value, format);
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
예제 #24
0
 public static BsonOid From(Oid val)
 {
     return new BsonOid(val);
 }
예제 #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Document"/> class. 
 /// </summary>
 /// <remarks>
 /// For testing/internal use only...by specifying the Oid, you are simulating the arrival of the document from a server
 /// </remarks>
 /// <param name="id">The id.</param>
 public Document(Oid id)
     : this(id, false)
 {
 }
예제 #26
0
 void element_ref(string name, string ns, Oid oid)
 {
     element_type(TypeByte.REF);
     element_name(name);
     WriteLengthPrefixedNullTerminated(ns);
     base.Write(oid.Buffer);
 }
예제 #27
0
 public void GetHashCodeTest()
 {
     Oid target = new Oid(); // TODO: Initialize to an appropriate value
     int expected = 0; // TODO: Initialize to an appropriate value
     int actual;
     actual = target.GetHashCode();
     actual.Should().Be(expected);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
예제 #28
0
 public void MachineTest()
 {
     Oid target = new Oid(); // TODO: Initialize to an appropriate value
     int actual;
     actual = target.Machine;
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
예제 #29
0
 public void TestQuoteCharacters()
 {
     bool thrown = false;
     Oid val = new Oid(@"""4a7067c30a57000000008ecb""");
     try{
         new Oid(val.ToString());
     }catch(ArgumentException ae){
         Assert.Fail("Creating an Oid from the json representation should not fail.");
     }
 }
예제 #30
-1
        public void TestFollowNonReference()
        {
            Database tests = mongo["tests"];
            Oid id = new Oid("BAD067c30a57000000008ecb");
            DBRef rf = new DBRef("reads", id);

            Document target = tests.FollowReference(rf);
            Assert.IsNull(target, "FollowReference returned wasn't null");
        }