示例#1
0
        public void InvoiceIdEmpty()
        {
            var payment = new Core.Data.Model.Payment();

            var ex = Assert.Throws <ArgumentException>(() => new Core.Logic.PaymentLogic().Save(payment));

            Assert.Equal("Invoice id most be specified to apply a payment", ex.Message);
        }
示例#2
0
        public void Successful()
        {
            // data
            var id      = Guid.NewGuid();
            var payment = new Core.Data.Model.Payment()
            {
                Id = id
            };

            // mocks
            var paymentPersistor = Mocks.StrictMock <Core.Data.Persistor.Payment>();
            var bll = Mocks.StrictMock <Core.Logic.PaymentLogic>(paymentPersistor);

            bll.Expect(b => b.Get(payment.Id)).CallOriginalMethod(OriginalCallOptions.NoExpectation);
            paymentPersistor.Expect(d => d.Get(payment.Id)).Return(payment);

            // record
            Mocks.ReplayAll();

            var result = bll.Get(id);

            Assert.Equal(id, result.Id);
        }
示例#3
0
        public void Successful()
        {
            var payment = new Core.Data.Model.Payment()
            {
                Invoice_Id = Guid.NewGuid()
            };

            // mocks
            var paymentPersistor = Mocks.StrictMock <Core.Data.Persistor.Payment>();
            var bll = Mocks.StrictMock <Core.Logic.PaymentLogic>(paymentPersistor);

            // record
            bll.Expect(b => b.Save(payment)).CallOriginalMethod(OriginalCallOptions.NoExpectation);
            paymentPersistor.Expect(u => u.Save(payment)).Return(payment);
            paymentPersistor.Expect(u => u.Commit()).Return(1);

            Mocks.ReplayAll();
            var result = bll.Save(payment);

            Assert.Equal(payment.Id, result.Id);

            Mocks.VerifyAll();
        }