-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
103 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace LiteDB.Tests | ||
{ | ||
#region Model | ||
|
||
public class CustomType | ||
{ | ||
public Regex Re1 { get; set; } | ||
public Regex Re2 { get; set; } | ||
|
||
public Uri Url { get; set; } | ||
public TimeSpan Ts { get; set; } | ||
} | ||
|
||
#endregion | ||
|
||
[TestClass] | ||
public class CustomTypeTest | ||
{ | ||
[TestMethod] | ||
public void CustomType_Test() | ||
{ | ||
var mapper = new BsonMapper(); | ||
var o = new CustomType | ||
{ | ||
Re1 = new Regex("^a+"), | ||
Re2 = new Regex("^a*", RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace), | ||
Url = new Uri("http://www.litedb.org"), | ||
Ts = TimeSpan.FromSeconds(10) | ||
}; | ||
|
||
var doc = mapper.ToDocument(o); | ||
var no = mapper.ToObject<CustomType>(doc); | ||
|
||
Assert.AreEqual("^a+", doc["Re1"].AsString); | ||
Assert.AreEqual("^a*", doc["Re2"].AsDocument["p"].AsString); | ||
|
||
Assert.AreEqual(o.Re1.ToString(), no.Re1.ToString()); | ||
Assert.AreEqual(o.Re2.ToString(), no.Re2.ToString()); | ||
Assert.AreEqual(o.Re2.Options, no.Re2.Options); | ||
Assert.AreEqual(o.Url, no.Url); | ||
Assert.AreEqual(o.Ts, no.Ts); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters