コード例 #1
0
        public void AddNewPay()
        {
            //Setup

            var provider = new Provider()
            {
                PersonId = 1,
                Name     = "Carlos",
                LastName = "Mambrake",
            };

            var pay = new Pay()
            {
                Date         = DateTime.Now,
                Provider     = provider,
                ProviderId   = 1,
                Certificated = false,
            };

            dataServiceMock.Setup(m => m.Insert <Pay>(pay))
            .Returns(new Pay()
            {
                PayId        = 1,
                Date         = pay.Date,
                Provider     = pay.Provider,
                ProviderId   = 1,
                Certificated = false,
                SaleList     = pay.SaleList,
            }).Verifiable();

            var payManager = new PayManager(dataServiceMock.Object);
            var salesList  = payManager.GetPendingToLiquidateSales(provider);

            pay.SaleList = salesList;

            //Act
            var payExpected = payManager.Add(pay);

            //Asserts
            dataServiceMock.Verify(m => m.Update <Sale>(It.IsAny <Sale>()), Times.Exactly(2));
            dataServiceMock.Verify();

            Assert.AreEqual(1, payExpected.PayId);
            Assert.AreEqual(SaleState.Liquidated, sales.ElementAt(0).SaleState);
            Assert.AreEqual(SaleState.Liquidated, sales.ElementAt(1).SaleState);
        }
コード例 #2
0
        public void AddNewPayWithSaleInvalid()
        {
            //setup
            var sale = sales.ElementAt(4);
            var pay  = new Pay()
            {
                Date     = DateTime.Now,
                Provider = new Provider()
                {
                    PersonId = 1, Name = "Carlos", LastName = "Mambrake"
                },
                ProviderId = 1,
            };

            pay.SaleList.Add(sale);
            PayManager payManager = new PayManager(dataServiceMock.Object);

            //Act and Assert
            Assert.ThrowsException <Exception>(() => payManager.Add(pay));
        }