Skip to content

Commit

Permalink
Add copy constructor for Oid.
Browse files Browse the repository at this point in the history
  • Loading branch information
lanwin committed May 22, 2010
1 parent 34b772a commit bade4b4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
13 changes: 11 additions & 2 deletions source/MongoDB.Tests/UnitTests/TestOid.cs
Expand Up @@ -88,7 +88,7 @@ public void TestFormatJ()
}

[Test]
public void TestIDCharacters()
public void TestIdCharacters()
{
var thrown = false;
try
Expand All @@ -103,7 +103,7 @@ public void TestIDCharacters()
}

[Test]
public void TestIDLength()
public void TestIdLength()
{
var thrown = false;
try
Expand Down Expand Up @@ -247,5 +247,14 @@ public void TestToByteArray()
Assert.AreEqual(12, bytes2.Length);
Assert.AreEqual(bytes, bytes2);
}

[Test]
public void TestCopyConstructor()
{
var source = Oid.NewOid();
var dest = new Oid(source);

Assert.AreEqual(source,dest);
}
}
}
12 changes: 12 additions & 0 deletions source/MongoDB/Oid.cs
Expand Up @@ -51,6 +51,18 @@ public Oid(byte[] value)
Array.Copy(value, _bytes, 12);
}

/// <summary>
/// Initializes a new instance of the <see cref="Oid"/> class.
/// </summary>
/// <param name="oid">The oid.</param>
public Oid(Oid oid)
{
if(oid == null)
throw new ArgumentNullException("oid");

_bytes = oid._bytes;
}

/// <summary>
/// Gets the created.
/// </summary>
Expand Down

0 comments on commit bade4b4

Please sign in to comment.