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.
MultipleDataAccessTest.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Reflection;
5using System.Text;
6using System.Threading.Tasks;
7using Csla.TestHelpers;
8using Microsoft.VisualStudio.TestTools.UnitTesting;
9
11{
12 [TestClass]
14 {
15 private static TestDIContext _testDIContext;
16
18 public static void ClassInitialize(TestContext context)
19 {
20 _testDIContext = TestDIContextFactory.CreateDefaultContext();
21 }
22
23 [TestMethod]
24 public void TestDpFetch()
25 {
26 IDataPortal<MultipleDataAccess> dataPortal = _testDIContext.CreateDataPortal<MultipleDataAccess>();
28
29 var result = dataPortal.Fetch(1);
30 Assert.AreEqual(1, result.Id);
31 Assert.AreEqual("abc", result.Name);
32
33 result = dataPortal.Fetch();
34 Assert.AreEqual(int.MaxValue, result.Id);
35 Assert.AreEqual(string.Empty, result.Name);
36
37 result = dataPortal.Fetch(new List<int?>());
38 Assert.AreEqual("Fetch(List<int?> values)", TestResults.GetResult("Method"));
39
40 result = dataPortal.Fetch(new List<DateTime?>());
41 Assert.AreEqual("Fetch(List<DateTime?> values)", TestResults.GetResult("Method"));
42 }
43
44 [TestMethod]
45 [ExpectedException(typeof(AmbiguousMatchException), "Should throw 'AmbiguousMatchException'")]
46 public void TestDpFetchNullable()
47 {
48 IDataPortal<MultipleDataAccess> dataPortal = _testDIContext.CreateDataPortal<MultipleDataAccess>();
49
50 try
51 {
52 var result = dataPortal.Fetch(1, default(bool?));
53 }
54 catch (DataPortalException ex)
55 {
56 throw ex.GetBaseException();
57 }
58 }
59 }
60}
This exception is returned for any errors occurring during the server-side DataPortal invocation.
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
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
object Fetch(params object[] criteria)
Called by a factory method in a business class to retrieve an object, which is loaded with values fro...