Beispiel #1
0
        public void TestSaveAllNull()
        {
            StandardBroker <Bean> broker = new StandardBroker <Bean>("name");

            TestStore <Bean> .ExceptionOnCall = false;
            broker.SaveAll(null);
        }
Beispiel #2
0
        public void TestSaveAll()
        {
            StandardBroker <StateBean> broker = new StandardBroker <StateBean>("name");

            TestStore <StateBean> .ExceptionOnCall = false;
            TestStore <StateBean> .PutList.Clear();

            TestStore <StateBean> .RemoveList.Clear();

            List <StateBean> list = new List <StateBean>();
            StateBean        bean = new StateBean();

            bean.Id    = 1;
            bean.Name  = "1";
            bean.State = ChangeAction.Insert;
            list.Add(bean);

            bean       = new StateBean();
            bean.Id    = 2;
            bean.Name  = "2";
            bean.State = ChangeAction.Delete;
            list.Add(bean);

            bean       = new StateBean();
            bean.Id    = 3;
            bean.Name  = "3";
            bean.State = ChangeAction.Update;
            list.Add(bean);

            bean       = new StateBean();
            bean.Id    = 4;
            bean.Name  = "4";
            bean.State = ChangeAction.None;
            list.Add(bean);

            broker.SaveAll(list);

            bool isAddedPut    = false;
            bool isModifiedPut = false;

            foreach (StateBean b in TestStore <StateBean> .PutList)
            {
                if (b.State == ChangeAction.Insert)
                {
                    if (isAddedPut)
                    {
                        Assert.Fail();
                    }
                    isAddedPut = true;
                }
                else if (b.State == ChangeAction.Update)
                {
                    if (isModifiedPut)
                    {
                        Assert.Fail();
                    }
                    isModifiedPut = true;
                }
                else
                {
                    Assert.Fail();
                }
            }
            Assert.IsTrue(isAddedPut);
            Assert.IsTrue(isModifiedPut);

            bool isDeletedRemove = false;

            foreach (object pk in TestStore <StateBean> .RemoveList)
            {
                if ((int)pk == 2)
                {
                    if (isDeletedRemove)
                    {
                        Assert.Fail();
                    }
                    isDeletedRemove = true;
                }
                else
                {
                    Assert.Fail();
                }
            }
            Assert.IsTrue(isDeletedRemove);
        }