Пример #1
0
        public void TestAddMoneyToCard()
        {
            CardModel objCard = new CardModel();

            objCard.Id               = 4;
            objCard.TypeId           = 4;
            objCard.CardValueBalance = 0;
            objCard.Name             = "RabbitB";

            Log objAddMoney = new Log();

            objAddMoney.AddMoney = 100;

            Mock <ICardStorage> mockCardStorage = new Mock <ICardStorage>();

            mockCardStorage.Setup(x => x.AddMoney(objCard, objAddMoney))
            .Returns(new CardModel()
            {
                Id               = 4,
                TypeId           = 4,
                Name             = "RabbitB",
                CardValueBalance = 100,
                CreatedTime      = DateTime.Parse("2018-10-19 06:34:00.1496640")
            });
            CardService serviceGetCardAfterAddMony = new CardService(mockCardStorage.Object);
            var         getCardPreview             = serviceGetCardAfterAddMony.AddMoneyToCard(objCard, objAddMoney);

            Assert.Equal(4, getCardPreview.Id);
            Assert.Equal(4, getCardPreview.TypeId);
            Assert.Equal("RabbitB", getCardPreview.Name);
            Assert.Equal(100, getCardPreview.CardValueBalance);
            Assert.Equal(DateTime.Parse("2018-10-19 06:34:00.1496640"), getCardPreview.CreatedTime);

            mockCardStorage.Verify(x => x.AddMoney(objCard, objAddMoney), Times.Once);
        }