Beispiel #1
0
        public void CreateDeckAndDeleteDeck()
        {
            //-- Arrange
            var newDeck = new DeckForCreationDto
            {
                Name = "test deck"
            };

            //-- Act
            var response = _decks.CreateDeck(newDeck, jsonMediaType).Result as CreatedAtRouteResult;

            var newDeckId   = (int)response.RouteValues["deckId"];
            var createdDeck = _flashCardRepository.GetDeck(newDeckId);

            //-- Assert
            Assert.IsNotNull(response);
            Assert.AreEqual("test deck", createdDeck.Name);


            /*--------- delete the deck ------------*/
            //-- Act
            _decks.DeleteDeck(newDeckId);

            var getResponse = _decks.GetDecks(jsonMediaType).Result as OkObjectResult;
            var getResult   = getResponse.Value as IEnumerable <DeckDto>;

            //-- Assert
            Assert.AreEqual(3, getResult.Count());
        }
        public void DeleteDeckTest(string deckName, Type expectedResultType, bool storageAlreadyContainsDeck)
        {
            deckStorageMock.Setup(storage => storage.Delete(deckName))
            .Returns(storageAlreadyContainsDeck);

            var result = controller.DeleteDeck(deckName);

            result.Should().BeOfType(expectedResultType);
        }