9using System.Collections.Generic;
13using System.Threading.Tasks;
16using Microsoft.VisualStudio.TestTools.UnitTesting;
19using TestClass = NUnit.Framework.TestFixtureAttribute;
20using TestInitialize = NUnit.Framework.SetUpAttribute;
21using TestCleanup = NUnit.Framework.TearDownAttribute;
22using TestMethod = NUnit.Framework.TestAttribute;
25using System.Threading;
26using System.Globalization;
40 private CultureInfo CurrentCulture;
41 private CultureInfo CurrentUICulture;
47 _testDIContext = TestDIContextFactory.CreateDefaultContext();
53 CurrentCulture = Thread.CurrentThread.CurrentCulture;
54 CurrentUICulture = Thread.CurrentThread.CurrentUICulture;
60 Thread.CurrentThread.CurrentCulture = CurrentCulture;
61 Thread.CurrentThread.CurrentUICulture = CurrentUICulture;
72 Assert.AreEqual(created.Id, 0);
81 Assert.AreEqual(created.Id, 100);
99 Assert.IsNotNull(result);
100 Assert.AreEqual(0, result.Id);
109 Assert.IsNotNull(result);
110 Assert.AreEqual(123, result.Id);
117 var lck =
new AutoResetEvent(
false);
118 new Action(async () =>
125 Assert.Fail(
"Expected exception not thrown");
145 var list =
new List<int>(500);
146 for (var i = 0; i < 500; i++)
151 var tasks = list.AsParallel().Select(x => dataPortal.
CreateAsync());
152 await Task.WhenAll(tasks);
165 Assert.IsNotNull(result);
166 Assert.AreEqual(0, result.Id);
174 var result = await dataPortal.
FetchAsync(123);
175 Assert.IsNotNull(result);
176 Assert.AreEqual(123, result.Id);
183 var lck =
new AutoResetEvent(
false);
184 new Action(async () =>
190 var result = await dataPortal.
FetchAsync(9999);
191 Assert.Fail(
"Expected exception not thrown");
211 var list =
new List<int>(500);
212 for (var i = 0; i < 500; i++)
217 var tasks = list.AsParallel().Select(x => dataPortal.
FetchAsync());
218 await Task.WhenAll(tasks);
226 public async Task SaveAsync()
231 Assert.IsNotNull(result);
232 Assert.AreEqual(0, result.Id);
233 Assert.IsTrue(result.IsNew);
234 Assert.IsTrue(result.IsDirty);
235 result = await result.SaveAsync();
236 Assert.IsFalse(result.IsNew);
237 Assert.IsFalse(result.IsDirty);
241 public async Task SaveAsyncWithException()
244 await context.Assert.Try(async () =>
249 Assert.IsNotNull(result);
250 Assert.AreEqual(555, result.Id);
251 Assert.IsTrue(result.IsNew);
252 Assert.IsTrue(result.IsDirty);
253 var lck =
new AutoResetEvent(
false);
254 new Action(async () =>
258 result = await result.SaveAsync();
259 Assert.Fail(
"Expected exception not thrown");
271 context.Assert.Success();
278 #region ExecuteCommand
285 var command = dataPortal.
Create();
287 Assert.AreEqual(
"Executed", result.AProperty);
297 Assert.IsNotNull(result);
298 Assert.AreEqual(124, result.Value);
304 var lck =
new AutoResetEvent(
false);
305 new Action(async () =>
311 var cmd = dataPortal.
Create(555);
313 Assert.Fail(
"Expected exception not thrown");
345 string expectedCulture = Thread.CurrentThread.
CurrentCulture.Name;
346 string expectedUICulture = Thread.CurrentThread.CurrentUICulture.Name;
348 var command = dataPortal.
Create();
350 Assert.AreEqual(expectedCulture, result.CurrentCulture);
351 Assert.AreEqual(expectedUICulture, result.CurrentUICulture);
This exception is returned for any errors occurring during the server-side DataPortal invocation.
async Task BeginCreate_Calling_BO_Without_DP_CREATE_Returns_no_Error_info()
Create is an exception , if BO does not have DP_Create() overload with that signature,...
async Task BeginCreate_with_exception()
static void ClassInitialize(TestContext context)
async Task CreateAsync_NoCriteria()
async Task ExecuteAsync()
async Task BeginFetch_sends_cultureinfo_to_dataportal()
async Task CreateAsync_WithCriteria()
async Task ExecuteCommand_called_without_UserState_results_in_UserState_defaulted_to_Null_server()
async Task BeginCreate_overload_without_parameters()
void FetchAsync_WithException()
async Task FetchAsync_WithCriteria()
void ExecuteAsyncWithException()
async Task CreateAsync_Parrallel()
async Task FetchAsync_Parrallel()
async Task FetchAsync_NoCriteria()
void CreateAsync_WithException()
async Task BeginCreate_overload_with_Criteria_passed_and_Id_set()
Type to carry context information for DI in unit tests
UnitTestContext GetContext()
Interface defining the members of the data portal type.
Task< object > CreateAsync(params object[] criteria)
Starts an asynchronous data portal operation to create a business object.
Task< object > ExecuteAsync(object command)
Called by a factory method in a business class or by the UI to execute a command object.
object Create(params object[] criteria)
Called by a factory method in a business class to create a new object, which is loaded with default v...
Task< object > FetchAsync(params object[] criteria)
Starts an asynchronous data portal operation to create a business object.