public void CreateCharacter__WithNullRequest() { #region Arrange var controller = new StarsWarsController(_starsWarsManager); CharacterRequest request = null; #endregion #region Act var response = controller.CreateCharacter(request); #endregion #region Assert Assert.IsInstanceOfType(response, typeof(BadRequestErrorMessageResult)); #endregion }
public void CreateCharacter__DuplicatedRequest() { #region Arrange var controller = new StarsWarsController(_starsWarsManager); CharacterRequest request = new CharacterRequest() { Name = "Chewbacca" }; #endregion #region Act var response = controller.CreateCharacter(request) as NegotiatedContentResult <CharacterResponse>; #endregion #region Assert Assert.IsNotNull(response); Assert.AreEqual($"Character {request.Name} already exists", response.Content.Message); Assert.AreEqual(422, (int)response.StatusCode); #endregion }
public void CreateCharacter__WithGoodRequest() { #region Arrange var controller = new StarsWarsController(_starsWarsManager); CharacterRequest request = new CharacterRequest() { Name = "Chewbacca" }; #endregion #region Act var response = controller.CreateCharacter(request) as NegotiatedContentResult <CharacterResponse>; #endregion #region Assert Assert.IsNotNull(response); Assert.IsNotNull(response.Content); Assert.AreEqual(201, (int)response.StatusCode); #endregion }