示例#1
0
        public void ExecuteAsyncWithException()
        {
            var lck = new AutoResetEvent(false);

            new Action(async() =>
            {
                IDataPortal <SingleCommand> dataPortal = _testDIContext.CreateDataPortal <SingleCommand>();

                try
                {
                    var cmd    = dataPortal.Create(555);
                    var result = await dataPortal.ExecuteAsync(cmd);
                    Assert.Fail("Expected exception not thrown");
                }
                catch (Exception ex)
                {
                    Assert.IsInstanceOfType(ex, typeof(Csla.DataPortalException));
                }
                finally
                {
                    lck.Set();
                }
            }).Invoke();
            lck.WaitOne();
        }
示例#2
0
        public async Task ExecuteCommand_called_without_UserState_results_in_UserState_defaulted_to_Null_server()
        {
            IDataPortal <CommandObject> dataPortal = _testDIContext.CreateDataPortal <CommandObject>();

            var command = dataPortal.Create();
            var result  = await dataPortal.ExecuteAsync(command);

            Assert.AreEqual("Executed", result.AProperty);
        }
示例#3
0
        public async Task ExecuteAsync()
        {
            IDataPortal <SingleCommand> dataPortal = _testDIContext.CreateDataPortal <SingleCommand>();

            SingleCommand cmd    = dataPortal.Create(123);
            var           result = await dataPortal.ExecuteAsync(cmd);

            Assert.IsNotNull(result);
            Assert.AreEqual(124, result.Value);
        }
示例#4
0
        public async Task BeginFetch_sends_cultureinfo_to_dataportal()
        {
            IDataPortal <AsyncPortalWithCulture> dataPortal = _testDIContext.CreateDataPortal <AsyncPortalWithCulture>();

            string expectedCulture   = Thread.CurrentThread.CurrentCulture.Name;
            string expectedUICulture = Thread.CurrentThread.CurrentUICulture.Name;

            var command = dataPortal.Create();
            var result  = await dataPortal.ExecuteAsync(command);

            Assert.AreEqual(expectedCulture, result.CurrentCulture);
            Assert.AreEqual(expectedUICulture, result.CurrentUICulture);
        }