Beispiel #1
0
        public async Task Update_Should_Return_Ok()
        {
            // Arrange.
            var manager = new Mock <ITemplateManager>();

            manager.Setup(m => m.UpdateTemplate(It.IsAny <MessageTemplate>()))
            .ReturnsAsync(true);
            MessageTemplatesController controller = GetController(manager);

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

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

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

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

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