
3 changed files with 69 additions and 1 deletions
-
2Bson/DefaultSerializer/Attributes/BsonKnownTypesAttribute.cs
-
2DriverOnlineTests/DriverOnlineTests.csproj
-
66DriverOnlineTests/Jira/CSharp100Tests.cs
@ -0,0 +1,66 @@ |
|||
/* 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.Runtime.Serialization; |
|||
using System.Text; |
|||
using NUnit.Framework; |
|||
|
|||
using MongoDB.Bson; |
|||
using MongoDB.Bson.DefaultSerializer; |
|||
using MongoDB.Driver; |
|||
using MongoDB.Driver.Builders; |
|||
|
|||
namespace MongoDB.DriverOnlineTests.Jira.CSharpxx { |
|||
[TestFixture] |
|||
public class CSharp100Tests { |
|||
[DataContract] |
|||
private class ParentClass { |
|||
[BsonId] |
|||
public ObjectId Id { get; set; } |
|||
} |
|||
|
|||
[DataContract] |
|||
private class ChildClass : ParentClass { |
|||
[DataMember(Order = 1)] |
|||
[BsonIgnoreIfNull] |
|||
public IList<SomeClass> SomeProperty { get; set; } |
|||
} |
|||
|
|||
[DataContract] |
|||
public class SomeClass { |
|||
} |
|||
|
|||
[Test] |
|||
public void TestDeserializationOfTwoBs() { |
|||
var server = MongoServer.Create("mongodb://localhost/?safe=true"); |
|||
var database = server["onlinetests"]; |
|||
var collection = database["csharpxx"]; |
|||
|
|||
collection.RemoveAll(); |
|||
var obj = new ChildClass { SomeProperty = null }; |
|||
collection.Save(obj, SafeMode.True); |
|||
obj = new ChildClass { SomeProperty = new List<SomeClass>() }; |
|||
collection.Save(obj, SafeMode.True); |
|||
obj = new ChildClass { SomeProperty = new List<SomeClass> { new SomeClass() } }; |
|||
collection.Save(obj, SafeMode.True); |
|||
obj = new ChildClass { SomeProperty = new List<SomeClass> { new SomeClass(), new SomeClass() } }; |
|||
collection.Save(obj, SafeMode.True); |
|||
} |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue