Example #1
0
        public async Task Add_Should_Return_Created()
        {
            // Arrange.
            MessageTemplatesController controller = GetController();

            templateModelRequest.Name = "new";

            // Act.
            var result = await controller.Add(templateModelRequest) as ObjectResult;

            // Assert.
            Assert.Equal((int)HttpStatusCode.Created, result.StatusCode);
        }
Example #2
0
        public async Task Add_Should_Return_Error_When_Exception_Was_Thrown(Type exceptionType)
        {
            // Arrange.
            var manager = new Mock <ITemplateManager>();

            manager.Setup(m => m.AddTemplate(It.IsAny <MessageTemplate>()))
            .ThrowsAsync((Exception)Activator.CreateInstance(exceptionType));
            MessageTemplatesController controller = GetController(manager);

            // Act.
            var result = await Assert.ThrowsAnyAsync <Exception>(() => controller.Add(templateModelRequest));

            // Assert.
            Assert.Equal(exceptionType, result.GetType());
        }