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.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
SplitTest.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="SplitTest.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;
12using Csla.TestHelpers;
13
14#if !NUNIT
15using Microsoft.VisualStudio.TestTools.UnitTesting;
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
25{
26 [TestClass]
27 public class SplitTest
28 {
29 private static TestDIContext _testDIContext;
30
32 public static void ClassInitialize(TestContext context)
33 {
34 _testDIContext = TestDIContextFactory.CreateDefaultContext();
35 }
36
37 [TestMethod]
38 public void TestDpCreate()
39 {
40 IDataPortal<Split> dataPortal = _testDIContext.CreateDataPortal<Split>();
41
42 Split test = Split.NewObject(dataPortal);
43 Assert.AreEqual("Created", TestResults.GetResult("Split"));
44 }
45 [TestMethod]
46 public void TestDpFetch()
47 {
48 IDataPortal<Split> dataPortal = _testDIContext.CreateDataPortal<Split>();
49
50 Split test = Split.GetObject(5, dataPortal);
51 Assert.AreEqual("Fetched", TestResults.GetResult("Split"));
52 }
53 [TestMethod]
54 public void TestDpInsert()
55 {
56 IDataPortal<Split> dataPortal = _testDIContext.CreateDataPortal<Split>();
57
58 Split test = null;
59 try
60 {
61 test = Split.NewObject(dataPortal);
62 }
63 catch { Assert.Inconclusive(); }
64 test.Save();
65 Assert.AreEqual("Inserted", TestResults.GetResult("Split"));
66 }
67 [TestMethod]
68 public void TestDpUpdate()
69 {
70 IDataPortal<Split> dataPortal = _testDIContext.CreateDataPortal<Split>();
71
72 Split test = null;
73 try
74 {
75 test = Split.NewObject(dataPortal);
76 test = test.Save();
77 test.Id = 5;
78 }
79 catch { Assert.Inconclusive(); }
80 test.Save();
81 Assert.AreEqual("Updated", TestResults.GetResult("Split"));
82 }
83 [TestMethod]
84 public void TestDpDelete()
85 {
86 IDataPortal<Split> dataPortal = _testDIContext.CreateDataPortal<Split>();
87
88 Split.DeleteObject(5, dataPortal);
89 Assert.AreEqual("Deleted", TestResults.GetResult("Split"));
90 }
91 [TestMethod]
92 public void TestDpDeleteSelf()
93 {
94 IDataPortal<Split> dataPortal = _testDIContext.CreateDataPortal<Split>();
95
96 Split test = null;
97 try
98 {
99 test = Split.NewObject(dataPortal);
100 test = test.Save();
101 test.Delete();
102 }
103 catch { Assert.Inconclusive(); }
104 test.Save();
105 Assert.AreEqual("SelfDeleted", TestResults.GetResult("Split"));
106 }
107
108 }
109}
static void DeleteObject(int id, IDataPortal< T > dataPortal)
Definition: SplitBase.cs:43
static T NewObject(IDataPortal< T > dataPortal)
Definition: SplitBase.cs:33
static T GetObject(int id, IDataPortal< T > dataPortal)
Definition: SplitBase.cs:38
static void ClassInitialize(TestContext context)
Definition: SplitTest.cs:32
Static dictionary-like class that offers similar functionality to GlobalContext This is used in tests...
Definition: TestResults.cs:21
static string GetResult(string key)
Get a result of an operation from the underlying results dictionary
Definition: TestResults.cs:49
Type to carry context information for DI in unit tests
Interface defining the members of the data portal type.
Definition: IDataPortalT.cs:17