CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
Csla.test/Nullable/NullableTests.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="NullableTests.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>no summary</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Collections.Generic;
10using System.Text;
11using Csla.TestHelpers;
12
13#if !NUNIT
14using Microsoft.VisualStudio.TestTools.UnitTesting;
15
16#else
17using NUnit.Framework;
18using TestClass = NUnit.Framework.TestFixtureAttribute;
19using TestInitialize = NUnit.Framework.SetUpAttribute;
20using TestCleanup = NUnit.Framework.TearDownAttribute;
21using TestMethod = NUnit.Framework.TestAttribute;
22#endif
23
24namespace Csla.Test.Nullable
25{
26 [TestClass()]
27 public class NullableTests
28 {
29 private static TestDIContext _testDIContext;
30
32 public static void ClassInitialize(TestContext context)
33 {
34 _testDIContext = TestDIContextFactory.CreateDefaultContext();
35 }
36
37 [TestMethod()]
38 [TestCategory("SkipWhenLiveUnitTesting")]
40 {
41 IDataPortal<NullableObject> dataPortal = _testDIContext.CreateDataPortal<NullableObject>();
42
44 NullableObject nullRoot = NullableObject.NewNullableObject(dataPortal);
45 nullRoot.NullableInteger = null;
46 nullRoot.Name = null;
47 Assert.AreEqual(null, nullRoot.Name);
48 Assert.AreEqual(null, nullRoot.NullableInteger);
49 }
50
51 [TestMethod()]
52 [TestCategory("SkipWhenLiveUnitTesting")]
53 public void TestNullableField()
54 {
55 IDataPortal<NullableObject> dataPortal = _testDIContext.CreateDataPortal<NullableObject>();
56
58 NullableObject nullRoot = NullableObject.NewNullableObject(dataPortal);
59 nullRoot._nullableIntMember = null;
60 Assert.AreEqual(null, nullRoot._nullableIntMember);
61 }
62
63 [TestMethod()]
64 [TestCategory("SkipWhenLiveUnitTesting")]
66 {
67 IDataPortal<NullableObject> dataPortal = _testDIContext.CreateDataPortal<NullableObject>();
68
70 NullableObject nullRoot = NullableObject.NewNullableObject(dataPortal);
71 nullRoot._nullableIntMember = null;
72 nullRoot.NullableInteger = null;
73 NullableObject nullRoot2 = nullRoot.Clone();
74 Assert.AreEqual(null, nullRoot2._nullableIntMember);
75 Assert.AreEqual(null, nullRoot2.NullableInteger);
76 }
77
78 [TestMethod()]
79 [TestCategory("SkipWhenLiveUnitTesting")]
81 {
82 IDataPortal<NullableObject> dataPortal = _testDIContext.CreateDataPortal<NullableObject>();
83
85 NullableObject nullRoot = NullableObject.NewNullableObject(dataPortal);
86 nullRoot.NullableInteger = null;
87 nullRoot._nullableIntMember = null;
88
89 nullRoot.BeginEdit();
90 nullRoot.NullableInteger = 45;
91 nullRoot._nullableIntMember = 32;
92 nullRoot.ApplyEdit();
93
94 Assert.AreEqual(45, nullRoot.NullableInteger);
95 Assert.AreEqual(32, nullRoot._nullableIntMember);
96
97 nullRoot.BeginEdit();
98 nullRoot.NullableInteger = null;
99 nullRoot._nullableIntMember = null;
100 nullRoot.ApplyEdit();
101
102 Assert.AreEqual(null, nullRoot.NullableInteger);
103 Assert.AreEqual(null, nullRoot._nullableIntMember);
104
105 nullRoot.BeginEdit();
106 nullRoot.NullableInteger = 444;
107 nullRoot._nullableIntMember = 222;
108 nullRoot.CancelEdit();
109
110 Assert.AreEqual(null, nullRoot.NullableInteger);
111 Assert.AreEqual(null, nullRoot._nullableIntMember);
112 }
113 }
114}
T Clone()
Creates a clone of the object.
Definition: BusinessBase.cs:79
static NullableObject NewNullableObject(IDataPortal< NullableObject > dataPortal)
static void ClassInitialize(TestContext context)
Static dictionary-like class that offers similar functionality to GlobalContext This is used in tests...
Definition: TestResults.cs:21
static void Reinitialise()
Reinitialise the dictionary, clearing any existing results, ready for the next test
Definition: TestResults.cs:69
Type to carry context information for DI in unit tests
Interface defining the members of the data portal type.
Definition: IDataPortalT.cs:17