コード例 #1
0
        public void GetAll_Should_Return_Error_When_Exception_Was_Thrown(Type exceptionType)
        {
            // Arrange.
            var manager = new Mock <ITemplateManager>();

            manager.Setup(m => m.GetTemplatesPaged(It.IsAny <PageInfo>()))
            .Throws((Exception)Activator.CreateInstance(exceptionType));

            MessageTemplatesController controller = GetController(manager);

            // Act.
            var result = Assert.ThrowsAny <Exception>(() => controller.GetAll());

            // Assert.
            Assert.Equal(exceptionType, result.GetType());
        }
コード例 #2
0
        public void GetAll_Should_Return_Valid_Templates()
        {
            // Arrange.
            var model   = new AllTemplates();
            var manager = new Mock <ITemplateManager>();

            manager.Setup(m => m.GetTemplatesPaged(It.IsAny <PageInfo>()))
            .Returns(model);

            MessageTemplatesController controller = GetController(manager);

            // Act.
            ActionResult <AllTemplates> result = controller.GetAll(pageInfoRequest);

            // Assert.
            Assert.NotNull(result);
            Assert.Equal(model, result.Value);
        }