Skip to content

Commit d651828

Browse files
committed
added test for csharp 479.
1 parent 8751b77 commit d651828

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

BsonUnitTests/BsonUnitTests.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@
148148
<Compile Include="Jira\CSharp446Tests.cs" />
149149
<Compile Include="Jira\CSharp452Tests.cs" />
150150
<Compile Include="Jira\CSharp460Tests.cs" />
151+
<Compile Include="Jira\CSharp467Tests.cs" />
152+
<Compile Include="Jira\CSharp479Tests.cs" />
151153
<Compile Include="Jira\CSharp70Tests.cs" />
152154
<Compile Include="Jira\CSharp71Tests.cs" />
153155
<Compile Include="Jira\CSharp74Tests.cs" />

BsonUnitTests/Jira/CSharp479Tests.cs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/* Copyright 2010-2012 10gen Inc.
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
using System;
17+
using System.Collections.Generic;
18+
using System.Linq;
19+
using System.Text;
20+
using NUnit.Framework;
21+
22+
using MongoDB.Bson;
23+
using MongoDB.Bson.Serialization;
24+
using MongoDB.Bson.Serialization.Attributes;
25+
using MongoDB.Bson.Serialization.Options;
26+
27+
namespace MongoDB.BsonUnitTests.Jira
28+
{
29+
[TestFixture]
30+
public class CSharp479Tests
31+
{
32+
public class Test
33+
{
34+
[BsonRepresentation(BsonType.ObjectId)]
35+
public string[] OtherIds { get; set;}
36+
}
37+
38+
[Test]
39+
public void TestRoundTripping()
40+
{
41+
var id1 = ObjectId.GenerateNewId().ToString();
42+
var id2 = ObjectId.GenerateNewId().ToString();
43+
44+
var test = new Test();
45+
test.OtherIds = new string[] { id1, id2 };
46+
47+
var bson = test.ToBson();
48+
var rehydrated = BsonSerializer.Deserialize<Test>(bson);
49+
50+
Assert.AreEqual(id1, test.OtherIds[0]);
51+
Assert.AreEqual(id2, test.OtherIds[1]);
52+
}
53+
}
54+
}

0 commit comments

Comments
 (0)