Browse Source
Implemented CSHARP-276. Added overloads of the BsonArray constructor and AddRange and Create methods that take a non-generic IEnumerable parameter. Also removed the BsonDocumentToBsonArray mapping in BsonTypeMapper because it conflicts with the new IEnumerable overloads (and it was a rather far-fetched mapping anyway).
pull/63/head
Implemented CSHARP-276. Added overloads of the BsonArray constructor and AddRange and Create methods that take a non-generic IEnumerable parameter. Also removed the BsonDocumentToBsonArray mapping in BsonTypeMapper because it conflicts with the new IEnumerable overloads (and it was a rather far-fetched mapping anyway).
pull/63/head

6 changed files with 96 additions and 8 deletions
-
42Bson/ObjectModel/BsonArray.cs
-
3Bson/ObjectModel/BsonTypeMapper.cs
-
1BsonUnitTests/BsonUnitTests.csproj
-
50BsonUnitTests/Jira/CSharp276Tests.cs
-
6BsonUnitTests/ObjectModel/BsonArrayTests.cs
-
2BsonUnitTests/ObjectModel/BsonTypeMapperTests.cs
@ -0,0 +1,50 @@ |
|||
/* Copyright 2010-2011 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; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using NUnit.Framework; |
|||
|
|||
using MongoDB.Bson; |
|||
|
|||
namespace MongoDB.BsonUnitTests.Jira { |
|||
[TestFixture] |
|||
public class CSharp276Tests { |
|||
[Test] |
|||
public void TestConstructorWithNonGenericIEnumerable() { |
|||
IEnumerable values = new object[] { 1, "a" }; |
|||
var array = new BsonArray(values); |
|||
Assert.AreEqual(2, array.Count); |
|||
Assert.AreEqual(BsonType.Int32, array[0].BsonType); |
|||
Assert.AreEqual(BsonType.String, array[1].BsonType); |
|||
Assert.AreEqual(1, array[0].AsInt32); |
|||
Assert.AreEqual("a", array[1].AsString); |
|||
} |
|||
|
|||
[Test] |
|||
public void TestCreateWithNonGenericIEnumerable() { |
|||
IEnumerable values = new object[] { 1, "a" }; |
|||
var array = BsonArray.Create(values); |
|||
Assert.AreEqual(2, array.Count); |
|||
Assert.AreEqual(BsonType.Int32, array[0].BsonType); |
|||
Assert.AreEqual(BsonType.String, array[1].BsonType); |
|||
Assert.AreEqual(1, array[0].AsInt32); |
|||
Assert.AreEqual("a", array[1].AsString); |
|||
} |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue