Пример #1
0
        public async Task ListTestSaveWhileBusy()
        {
            IDataPortal <ItemWithAsynchRuleList> dataPortal = _noCloneOnUpdateDIContext.CreateDataPortal <ItemWithAsynchRuleList>();

            TestResults.Reinitialise();

            UnitTestContext        context = GetContext();
            ItemWithAsynchRuleList items   = ItemWithAsynchRuleList.GetListWithItems(dataPortal);

            items[0].RuleField = "some value";
            context.Assert.IsTrue(items.IsBusy);
            context.Assert.IsFalse(items.IsSavable);

            try
            {
                await items.SaveAsync();
            }
            catch (Exception ex)
            {
                var error = ex as InvalidOperationException;
                context.Assert.IsNotNull(error);
                context.Assert.IsTrue(error.Message.ToLower().Contains("busy"));
                context.Assert.IsTrue(error.Message.ToLower().Contains("save"));
                context.Assert.Success();
            }
            context.Complete();
        }
Пример #2
0
        public void ListTestSaveWhileNotBusy()
        {
            System.Configuration.ConfigurationManager.AppSettings["CslaAutoCloneOnUpdate"] = "false";
            UnitTestContext        context = GetContext();
            ItemWithAsynchRuleList items   = ItemWithAsynchRuleList.GetListWithItems();

            items[0].ValidationComplete += async(o2, e2) =>
            {
                context.Assert.IsFalse(items.IsBusy);
                context.Assert.IsTrue(items.IsSavable);
                items = await items.SaveAsync();

                context.Assert.AreEqual("DataPortal_Update", items[0].OperationResult);
                context.Assert.Success();
            };

            items[0].RuleField = "some value";
            context.Assert.IsTrue(items.IsBusy);
            context.Assert.IsFalse(items.IsSavable);
            context.Complete();
        }
Пример #3
0
        public void ListTestSaveWhileNotBusy()
        {
            IDataPortal <ItemWithAsynchRuleList> dataPortal = _noCloneOnUpdateDIContext.CreateDataPortal <ItemWithAsynchRuleList>();

            UnitTestContext        context = GetContext();
            ItemWithAsynchRuleList items   = ItemWithAsynchRuleList.GetListWithItems(dataPortal);

            items[0].ValidationComplete += async(o2, e2) =>
            {
                context.Assert.IsFalse(items.IsBusy);
                context.Assert.IsTrue(items.IsSavable);
                items = await items.SaveAsync();

                context.Assert.AreEqual("DataPortal_Update", items[0].OperationResult);
                context.Assert.Success();
            };

            items[0].RuleField = "some value";
            context.Assert.IsTrue(items.IsBusy);
            context.Assert.IsFalse(items.IsSavable);
            context.Complete();
        }
Пример #4
0
        public async Task ListTestSaveWhileBusy()
        {
            System.Configuration.ConfigurationManager.AppSettings["CslaAutoCloneOnUpdate"] = "false";
            UnitTestContext        context = GetContext();
            ItemWithAsynchRuleList items   = ItemWithAsynchRuleList.GetListWithItems();

            items[0].RuleField = "some value";
            context.Assert.IsTrue(items.IsBusy);
            context.Assert.IsFalse(items.IsSavable);

            try
            {
                await items.SaveAsync();
            }
            catch (Exception ex)
            {
                var error = ex as InvalidOperationException;
                context.Assert.IsNotNull(error);
                context.Assert.IsTrue(error.Message.ToLower().Contains("busy"));
                context.Assert.IsTrue(error.Message.ToLower().Contains("save"));
                context.Assert.Success();
            }
            context.Complete();
        }