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.
RuleTests.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Reflection;
5using System.Text;
6using Microsoft.VisualStudio.TestTools.UnitTesting;
8using UnitDriven;
9using System.Threading.Tasks;
10using Csla.TestHelpers;
11
13{
14 [TestClass]
15 public class RuleTests : TestBase
16 {
17 private static TestDIContext _testDIContext;
18
20 public static void ClassInitialize(TestContext context)
21 {
22 _testDIContext = TestDIContextFactory.CreateDefaultContext();
23 }
24
25 [TestMethod]
27 {
28 IDataPortal<RootThrowsException> dataPortal = _testDIContext.CreateDataPortal<RootThrowsException>();
29
31
32 // AddBusinessRules throw an ArgumentException
33 // In .NET the exception will occur serverside and returned i DatPortalEventArgs
34 try
35 {
36 await dataPortal.CreateAsync();
37 }
38 catch (DataPortalException ex)
39 {
40 Assert.IsTrue(ex.InnerException is ArgumentException);
41 }
42
43 // should fail again as type rules should be cleaned up
44 // AddBusinessRules throw an ArgumentException
45 try
46 {
47 await dataPortal.CreateAsync();
48 }
49 catch (DataPortalException ex)
50 {
51 Assert.IsTrue(ex.InnerException is ArgumentException);
52 }
53 }
54 }
55}
This exception is returned for any errors occurring during the server-side DataPortal invocation.
async Task CleanupWhenAddBusinessRulesThrowsException()
Definition: RuleTests.cs:26
static void ClassInitialize(TestContext context)
Definition: RuleTests.cs:20
Type to carry context information for DI in unit tests
Interface defining the members of the data portal type.
Definition: IDataPortalT.cs:17
Task< object > CreateAsync(params object[] criteria)
Starts an asynchronous data portal operation to create a business object.