public async Task Delete_Should_Return_Error_When_Exception_Was_Thrown(Type exceptionType) { // Arrange. var manager = new Mock <ITemplateManager>(); manager.Setup(m => m.DeleteTemplate(It.IsAny <string>())) .ThrowsAsync((Exception)Activator.CreateInstance(exceptionType)); MessageTemplatesController controller = GetController(manager); // Act. var result = await Assert.ThrowsAnyAsync <Exception>(() => controller.Delete(TemplateName)); // Assert. Assert.Equal(exceptionType, result.GetType()); }
public async Task Delete_Should_Return_Ok() { // Arrange. var manager = new Mock <ITemplateManager>(); manager.Setup(m => m.DeleteTemplate(It.IsAny <string>())) .ReturnsAsync(true); MessageTemplatesController controller = GetController(manager); // Act. var result = await controller.Delete(TemplateName) as ObjectResult; // Assert. Assert.Equal((int)HttpStatusCode.OK, result.StatusCode); }