Beispiel #1
0
        public async Task <IHttpActionResult> Put([FromBody] CardUpdateDTO cardDTO)
        {
            if (cardDTO == null || !ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Card card = cardDTO.ToCard();

            CardUpdateResultEnum result = await _cardsService.UpdateCard(card);

            return(Ok(result));
        }
        public async Task Put_ShouldReturnIsDeactivated()
        {
            var dto = new CardUpdateDTO {
                CardGuid = Guid.NewGuid(), NewCardState = CardStates.CheckedIn
            };

            var cardsService = new Mock <ICardsService>();

            cardsService.Setup(cs => cs.UpdateCard(It.IsAny <Card>())).Returns(Task.FromResult(CardUpdateResultEnum.IsDeactivated));
            var controller = new CardsController(cardsService.Object);

            var actionResult = await controller.Put(dto);

            var response = actionResult as OkNegotiatedContentResult <CardUpdateResultEnum>;

            Assert.IsNotNull(response);
            Assert.AreEqual(response.Content, CardUpdateResultEnum.IsDeactivated);
        }