0
|
1 using System;
|
|
2 using System.Collections.Generic;
|
|
3 using System.Linq;
|
|
4 using System.Text;
|
|
5 using BLToolkit.Mapping;
|
|
6 using BLToolkit.Mapping.Fluent;
|
|
7 using NUnit.Framework;
|
|
8
|
|
9 namespace UnitTests.CS.Mapping
|
|
10 {
|
|
11 [TestFixture]
|
|
12 public class TestFluentNullable
|
|
13 {
|
|
14 public class TestObject
|
|
15 {
|
|
16 public string NullableString { get; set; }
|
|
17 }
|
|
18
|
|
19 public class TestObjectMap : FluentMap<TestObject>
|
|
20 {
|
|
21 public TestObjectMap ()
|
|
22 {
|
|
23 NullValue (x => x.NullableString, null).Nullable ();
|
|
24 }
|
|
25 }
|
|
26
|
|
27 [Test]
|
|
28 public void TestFluentNullValue ()
|
|
29 {
|
|
30 var schema = new MappingSchema ();
|
|
31 FluentConfig.Configure (schema).MapingFromType<TestObjectMap> ();
|
|
32 var om = schema.GetObjectMapper (typeof (TestObject));
|
|
33 var instance = new TestObject () { NullableString = "SOMEVALUE" };
|
|
34 om.SetValue (instance, "NullableString", null);
|
|
35 Assert.AreEqual (null, instance.NullableString);
|
|
36 }
|
|
37
|
|
38
|
|
39
|
|
40
|
|
41 }
|
|
42 }
|