예제 #1
0
        public virtual void PolymorphicCollectionAddMutlipleItemsOfOneType(string roleObjectType)
        {
            var payment = FindById <PolymorphicPayment>(4);
            var inv     = FindById <InvoiceAsPayableItem>(1);

            string      invId  = inv.GetPropertyByName("Id").Title;
            ITestObject inv2   = GetTestService("Invoice As Payable Items").GetAction("New Instance").InvokeReturnObject().Save();
            string      inv2Id = inv2.GetPropertyByName("Id").Title;


            ITestCollection links = payment.GetPropertyByName("Payable Item Links").ContentAsCollection;
            ITestCollection items = payment.GetPropertyByName("Payable Items").ContentAsCollection;

            links.AssertCountIs(0);
            items.AssertCountIs(0);

            //Add an Invoice
            payment.GetAction("Add Payable Item").InvokeReturnObject(inv);
            links.AssertCountIs(1);
            ITestObject link1 = links.ElementAt(0);

            link1.GetPropertyByName("Associated Role Object Type").AssertValueIsEqual(roleObjectType);
            link1.GetPropertyByName("Associated Role Object Id").AssertValueIsEqual(invId);
            items = payment.GetPropertyByName("Payable Items").ContentAsCollection;
            ITestObject item = items.AssertCountIs(1).ElementAt(0);

            item.AssertIsType(typeof(InvoiceAsPayableItem));

            //Add an expense claim
            payment.GetAction("Add Payable Item").InvokeReturnObject(inv2);
            links.AssertCountIs(2);
            ITestObject link2 = links.ElementAt(1);

            link2.GetPropertyByName("Associated Role Object Type").AssertValueIsEqual(roleObjectType);
            link2.GetPropertyByName("Associated Role Object Id").AssertValueIsEqual(inv2Id);
            items = payment.GetPropertyByName("Payable Items").ContentAsCollection;
            item  = items.AssertCountIs(2).ElementAt(1);
            item.AssertIsType(typeof(InvoiceAsPayableItem));
        }
        public virtual void PolymorphicCollectionAddDifferentItems(string roleType1, string roleType2)
        {
            var payment = FindById("Polymorphic Payments", 5);
            var inv     = FindById("Invoice As Payable Items", 1);

            string      invId = inv.GetPropertyByName("Id").Title;
            ITestObject exp   = GetTestService("Expense Claim As Payable Items").GetAction("New Instance").InvokeReturnObject().Save();
            string      expId = exp.GetPropertyByName("Id").Title;

            ITestCollection links = payment.GetPropertyByName("Payable Item Links").ContentAsCollection;
            ITestCollection items = payment.GetPropertyByName("Payable Items").ContentAsCollection;

            links.AssertCountIs(0);
            items.AssertCountIs(0);

            //Add an Invoice
            payment.GetAction("Add Payable Item").InvokeReturnObject(inv);
            links.AssertCountIs(1);
            ITestObject link1 = links.ElementAt(0);

            link1.GetPropertyByName("Associated Role Object Type").AssertValueIsEqual(roleType1);
            link1.GetPropertyByName("Associated Role Object Id").AssertValueIsEqual(invId);
            items = payment.GetPropertyByName("Payable Items").ContentAsCollection;
            ITestObject item = items.AssertCountIs(1).ElementAt(0);

            item.AssertIsType(typeof(InvoiceAsPayableItem));

            //Add an expense claim
            payment.GetAction("Add Payable Item").InvokeReturnObject(exp);
            links.AssertCountIs(2);
            ITestObject link2 = links.ElementAt(1);

            link2.GetPropertyByName("Associated Role Object Type").AssertValueIsEqual(roleType2);
            link2.GetPropertyByName("Associated Role Object Id").AssertValueIsEqual(expId);
            items = payment.GetPropertyByName("Payable Items").ContentAsCollection;
            item  = items.AssertCountIs(2).ElementAt(1);
            item.AssertIsType(typeof(ExpenseClaimAsPayableItem));
        }
예제 #3
0
        public virtual void RemoveItem()
        {
            var payment = FindById <PolymorphicPayment>(7);
            var inv     = FindById <InvoiceAsPayableItem>(1);

            ITestCollection links = payment.GetPropertyByName("Payable Item Links").ContentAsCollection;
            ITestCollection items = payment.GetPropertyByName("Payable Items").ContentAsCollection;

            links.AssertCountIs(1);
            items.AssertCountIs(1);
            Assert.AreEqual(inv, items.ElementAt(0));

            //Now remove the invoice
            payment.GetAction("Remove Payable Item").InvokeReturnObject(inv);
            links.AssertCountIs(0);
            items = payment.GetPropertyByName("Payable Items").ContentAsCollection;
            items.AssertCountIs(0);
        }
예제 #4
0
        public virtual void AttemptToAddSameItemTwice()
        {
            var    payment = FindById <PolymorphicPayment>(6);
            var    inv     = FindById <InvoiceAsPayableItem>(1);
            string invId   = inv.GetPropertyByName("Id").Title;

            ITestCollection links = payment.GetPropertyByName("Payable Item Links").ContentAsCollection;
            ITestCollection items = payment.GetPropertyByName("Payable Items").ContentAsCollection;

            links.AssertCountIs(1);
            items.AssertCountIs(1);
            Assert.AreEqual(inv, items.ElementAt(0));

            //Try adding same expense claim again
            payment.GetAction("Add Payable Item").InvokeReturnObject(inv);
            links.AssertCountIs(1); //Should still be 1
            items = payment.GetPropertyByName("Payable Items").ContentAsCollection;
            items.AssertCountIs(1);
        }