コード例 #1
0
        public void TestAddRoundToCard()
        {
            CardModel objCard = new CardModel();

            objCard.Id               = 3;
            objCard.TypeId           = 3;
            objCard.CardRoundBalance = 0;
            objCard.Name             = "RabbitA";

            Log objAddRound = new Log();

            objAddRound.AddRound = 15;

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

            mockCardStorage.Setup(x => x.AddRound(objCard, objAddRound))
            .Returns(new CardModel()
            {
                Id               = 3,
                TypeId           = 3,
                Name             = "RabbitA",
                CardRoundBalance = 30,
                CreatedTime      = DateTime.Parse("2018-10-19 06:34:00.1251290"),
                LastTimeAddRound = DateTime.Parse("2018-10-19 07:07:08.1991610")
            });
            CardService serviceGetCardAfterAddRound = new CardService(mockCardStorage.Object);
            var         getCardPreview = serviceGetCardAfterAddRound.AddRoundToCard(objCard, objAddRound);

            Assert.Equal(3, getCardPreview.Id);
            Assert.Equal(3, getCardPreview.TypeId);
            Assert.Equal("RabbitA", getCardPreview.Name);
            Assert.Equal(30, getCardPreview.CardRoundBalance);
            Assert.Equal(DateTime.Parse("2018-10-19 06:34:00.1251290"), getCardPreview.CreatedTime);
            Assert.Equal(DateTime.Parse("2018-10-19 07:07:08.1991610"), getCardPreview.LastTimeAddRound);
            mockCardStorage.Verify(x => x.AddRound(objCard, objAddRound), Times.Once);
        }