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.
LogicalExecutionLocationTests.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="LogicalExecutionLocationTests.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#else
16using NUnit.Framework;
17using TestClass = NUnit.Framework.TestFixtureAttribute;
18using TestInitialize = NUnit.Framework.SetUpAttribute;
19using TestCleanup = NUnit.Framework.TearDownAttribute;
20using TestMethod = NUnit.Framework.TestAttribute;
21#endif
22
24{
25 [TestClass]
27 {
28 private static TestDIContext _testDIContext;
29
31 public static void ClassInitialize(TestContext context)
32 {
33 _testDIContext = TestDIContextFactory.CreateDefaultContext();
34 }
35
36 [TestMethod]
38 {
39 IDataPortal<LocationBusinessBase> dataPortal = _testDIContext.CreateDataPortal<LocationBusinessBase>();
40 var applicationContext = _testDIContext.CreateTestApplicationContext();
41
42 Assert.AreEqual(ApplicationContext.LogicalExecutionLocations.Client, applicationContext.LogicalExecutionLocation, "Should be client");
43
44#pragma warning disable CS0436 // Type conflicts with imported type
46#pragma warning restore CS0436 // Type conflicts with imported type
47
48 Assert.AreEqual(Csla.ApplicationContext.LogicalExecutionLocations.Server.ToString(), item.Data, "Should be server");
49 Assert.AreEqual(Csla.ApplicationContext.LogicalExecutionLocations.Server.ToString(), item.NestedData, "Nested should be server");
50
51 Assert.AreEqual(Csla.ApplicationContext.LogicalExecutionLocations.Client, applicationContext.LogicalExecutionLocation, "Should be client");
52
53 }
54
55 [TestMethod]
57 {
58 IDataPortal<LocationBusinessBase> dataPortal = _testDIContext.CreateDataPortal<LocationBusinessBase>();
59
60#pragma warning disable CS0436 // Type conflicts with imported type
62#pragma warning restore CS0436 // Type conflicts with imported type
63
64 Assert.AreEqual(Csla.ApplicationContext.LogicalExecutionLocations.Server.ToString(), item.Rule, "Should be server");
65
66 item.Data = "random";
67 Assert.AreEqual(Csla.ApplicationContext.LogicalExecutionLocations.Client.ToString(), item.Rule, "Should be client");
68
69 }
70 }
71}
Provides consistent context information between the client and server DataPortal objects.
LogicalExecutionLocations
Enum representing the logical execution location The setting is set to server when server is execting...
static LocationBusinessBase GetLocationBusinessBase(IDataPortal< LocationBusinessBase > dataPortal)
Type to carry context information for DI in unit tests
Interface defining the members of the data portal type.
Definition: IDataPortalT.cs:17