public async Task MutantV1Controller_PostAsync_DtoNull_Succeeds() { //Arrange MutantV1Controller controller = GetMutantController(); _mutantServiceMock.Setup(x => x.IsMutantAsync(It.IsAny <Human>())).ThrowsAsync(new ArgumentNullException()).Verifiable(); //Action HttpResponseMessage result = await controller.PostAsync(null); //Asserts Assert.IsNotNull(result); Assert.AreEqual(HttpStatusCode.BadRequest, result.StatusCode); _mutantServiceMock.Verify(x => x.IsMutantAsync(It.IsAny <Human>()), Times.Once); }
public async Task MutantV1Controller_PostAsync_WrongDto_Succeeds() { //Arrange MutantV1Controller controller = UnityConfig.Resolve <MutantV1Controller>(); HumanV1Dto dto = new HumanV1Dto() { Dna = new string[] { "AAA", "CCC", "TTTXX" } }; //Action HttpResponseMessage result = await controller.PostAsync(dto); //Asserts Assert.IsNotNull(result); Assert.AreEqual(HttpStatusCode.BadRequest, result.StatusCode); }
public async Task MutantV1Controller_PostAsync_NonHandledException_Succeeds() { //Arrange MutantV1Controller controller = GetMutantController(); HumanV1Dto dto = new HumanV1Dto(); _mutantServiceMock.Setup(x => x.IsMutantAsync(It.IsAny <Human>())).ThrowsAsync(new Exception()).Verifiable(); //Action HttpResponseMessage result = await controller.PostAsync(dto); //Asserts Assert.IsNotNull(result); Assert.AreEqual(HttpStatusCode.InternalServerError, result.StatusCode); _mutantServiceMock.Verify(x => x.IsMutantAsync(It.IsAny <Human>()), Times.Once); }
public async Task MutantV1Controller_PostAsync_ValidDtoFullyMapped_Succeeds() { //Arrange MutantV1Controller controller = GetMutantController(); HumanV1Dto dto = new HumanV1Dto() { Dna = new string[] { "AAA", "CCC", "TTT" } }; _mutantServiceMock.Setup(x => x.IsMutantAsync(It.IsAny <Human>())).ReturnsAsync(true).Verifiable(); //Action HttpResponseMessage result = await controller.PostAsync(dto); //Asserts Assert.IsNotNull(result); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); _mutantServiceMock.Verify(x => x.IsMutantAsync(It.IsAny <Human>()), Times.Once); }