Browse Source
Fixed CSHARP-98. GetActualType needs to be a little more precise about where the reader is sitting when it is called.
pull/27/head
Fixed CSHARP-98. GetActualType needs to be a little more precise about where the reader is sitting when it is called.
pull/27/head

3 changed files with 86 additions and 25 deletions
-
54Bson/DefaultSerializer/Conventions/DiscriminatorConventions.cs
-
1DriverOnlineTests/DriverOnlineTests.csproj
-
56DriverOnlineTests/Jira/CSharp98Tests.cs
@ -0,0 +1,56 @@ |
|||
/* Copyright 2010 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.IO; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using NUnit.Framework; |
|||
|
|||
using MongoDB.Bson; |
|||
using MongoDB.Bson.DefaultSerializer; |
|||
using MongoDB.Driver; |
|||
using MongoDB.Driver.Builders; |
|||
|
|||
namespace MongoDB.DriverOnlineTests.Jira.CSharp98 { |
|||
[TestFixture] |
|||
public class CSharp98Tests { |
|||
private class A { |
|||
[BsonId] |
|||
public ObjectId Id { get; set; } |
|||
public int PA { get; set; } |
|||
} |
|||
|
|||
private class B : A { |
|||
public int PB { get; set; } |
|||
} |
|||
|
|||
[Test] |
|||
public void TestDeserializationOfTwoBs() { |
|||
var server = MongoServer.Create("mongodb://localhost/?safe=true"); |
|||
var database = server["onlinetests"]; |
|||
var collection = database.GetCollection<A>("csharp98"); |
|||
|
|||
collection.RemoveAll(); |
|||
var b1 = new B { PA = 1, PB = 2 }; |
|||
var b2 = new B { PA = 3, PB = 4 }; |
|||
collection.Insert<A>(b1); |
|||
collection.Insert<A>(b2); |
|||
|
|||
var docs = collection.FindAll().ToList(); |
|||
} |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue