예제 #1
0
        public void SimplePurchaseTest()
        {
            decimal creditExpected   = yearTop.GetAccount("credit").CurrentBalance;
            decimal checkingExpected = yearTop.GetAccount("checking").CurrentBalance;

            //transaction details
            decimal             amount;
            string              description;
            DateTime            date;
            SoftBillTransaction sbt;

            /* Credit checks */
            amount      = 100;
            description = "grocery store";
            date        = new DateTime(2020, 1, 15);
            sbt         = yearTop.GetSoftBillTransaction(description, amount, date.Month);
            sbt.Date    = date;
            sbt.SoftGroupSplit["food"] = amount;
            yearTop.GetAccount("credit").NewDebitTransaction(sbt);

            creditExpected += amount;
            Assert.AreEqual(creditExpected, yearTop.GetAccount("credit").CurrentBalance);

            /* Credit checks */
            amount      = 150;
            description = "grocery store";
            date        = new DateTime(2020, 1, 16);
            sbt         = yearTop.GetSoftBillTransaction(description, amount, date.Month);
            sbt.Date    = date;
            sbt.SoftGroupSplit["food"] = amount;
            yearTop.GetAccount("credit").NewDebitTransaction(sbt);

            creditExpected += amount;
            Assert.AreEqual(creditExpected, yearTop.GetAccount("credit").CurrentBalance);

            /* Checking checks */
            amount      = 150;
            description = "gas station";
            date        = new DateTime(2020, 1, 16);
            sbt         = yearTop.GetSoftBillTransaction(description, amount, date.Month);
            sbt.Date    = date;
            sbt.SoftGroupSplit["gas"] = amount;
            yearTop.GetAccount("checking").NewDebitTransaction(sbt);

            checkingExpected -= amount;
            Assert.AreEqual(checkingExpected, yearTop.GetAccount("checking").CurrentBalance);

            amount      = 50;
            description = "gas station";
            date        = new DateTime(2020, 1, 20);
            sbt         = yearTop.GetSoftBillTransaction(description, amount, date.Month);
            sbt.Date    = date;
            sbt.SoftGroupSplit["gas"] = amount;
            yearTop.GetAccount("checking").NewDebitTransaction(sbt);

            checkingExpected -= amount;
            Assert.AreEqual(checkingExpected, yearTop.GetAccount("checking").CurrentBalance);
        }