public void TestDecode() { string hex = "4a7067c30a57000000008ecb"; Oid oid = new Oid(hex); Assert.AreEqual("\"" + hex + "\"", oid.ToString()); }
public void TestDecode() { string hex = "4a7067c30a57000000008ecb"; Oid oid = new Oid(hex); Assert.AreEqual(hex,"ObjectId(\"" + oid.ToString() + "\")"); }
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); }
public void TestNewOidFromToString() { var hex = "4B458B95D114BE541B000000"; var firstOid = new Oid(hex); var secondOid = new Oid(firstOid.ToString()); Assert.AreEqual(firstOid.ToString(), secondOid.ToString()); }
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"); }
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."); }
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; }
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"]); }
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; }
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); }
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); }
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); }
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"); }
public void OidConstructorTest3() { Oid a = Oid.NewOid(); Oid b = new Oid(a); a.Should().Be(b); }
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); }
public BsonOid(Oid oid) { this.val = oid.Value; }
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."); }
void element_oid(string name, Oid oid) { element_type(TypeByte.OID); element_name(name); base.Write(oid.Buffer); }
public DBRef(string collectionName, Oid id) { this.CollectionName = collectionName; this.Id = id.Value; }
/// <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; }
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."); }
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"); }
public static BsonOid From(Oid val) { return new BsonOid(val); }
/// <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) { }
void element_ref(string name, string ns, Oid oid) { element_type(TypeByte.REF); element_name(name); WriteLengthPrefixedNullTerminated(ns); base.Write(oid.Buffer); }
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."); }
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."); }
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."); } }
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"); }