Browse Source
CSHARP-595: corrected issue with infinite recursion when converting a BsonValue to another BsonValue.
pull/134/head
CSHARP-595: corrected issue with infinite recursion when converting a BsonValue to another BsonValue.
pull/134/head

4 changed files with 161 additions and 2 deletions
-
2Bson/ObjectModel/BsonValue.cs
-
104Bson/ObjectModel/ObjectId.cs
-
1BsonUnitTests/BsonUnitTests.csproj
-
56BsonUnitTests/Jira/CSharp595Tests.cs
@ -0,0 +1,56 @@ |
|||
/* Copyright 2010-2012 10gen Inc. |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using NUnit.Framework; |
|||
|
|||
using MongoDB.Bson; |
|||
using MongoDB.Bson.Serialization; |
|||
|
|||
namespace MongoDB.BsonUnitTests.Jira.CSharp595 |
|||
{ |
|||
[TestFixture] |
|||
public class CSharp595Tests |
|||
{ |
|||
[Test] |
|||
public void TestDoesNotThrowStackOverflowExceptionWhenConvertingToSelfType() |
|||
{ |
|||
BsonObjectId id1 = BsonObjectId.GenerateNewId(); |
|||
BsonObjectId id2 = null; |
|||
Assert.DoesNotThrow(() => |
|||
{ |
|||
id2 = (BsonObjectId)((IConvertible)id1).ToType(typeof(BsonObjectId), null); |
|||
}); |
|||
|
|||
Assert.AreEqual(id1, id2); |
|||
} |
|||
|
|||
[Test] |
|||
public void TestDoesNotThrowStackOverflowExceptionWhenConvertingToBsonString() |
|||
{ |
|||
BsonObjectId id1 = BsonObjectId.GenerateNewId(); |
|||
BsonString id2 = null; |
|||
Assert.DoesNotThrow(() => |
|||
{ |
|||
id2 = (BsonString)((IConvertible)id1).ToType(typeof(BsonString), null); |
|||
}); |
|||
|
|||
Assert.AreEqual(id1.ToString(), id2.AsString); |
|||
} |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue