-
-
Notifications
You must be signed in to change notification settings - Fork 10
Mocking controllers and views
Alexanderius edited this page Jul 3, 2025
·
2 revisions
Mocking of views and controllers is available by default because all controller base properties are virtual. You can use mocking frameworks such as Moq to do mocking.
Testing that the default controller returns StaticTpl
with the "Default" template name to load.
[Get("/")]
public class DefaultController : Controller
{
public override ControllerResponse Invoke()
{
return new StaticTpl("Default");
}
}
[TestFixture]
public class DefaultPageControllerTests
{
[Test]
public void Invoke_Default_MainContentSet()
{
// Arrange
var c = new Mock<DefaultController> { CallBase = true };
// Act
var result = c.Object.Invoke();
// Assert
Assert.AreEqual("Default", ((StaticTpl)result).TemplateFileName);
}
}
- Getting Started
- Main Simplify.Web principles
- Simplify.Web controllers
- Simplify.Web views
- Simplify.Web templates
- Simplify.Web configuration
- Templates variables
- Static content
- Template factory
- Data collector
- String table
- File reader
- Web context
- Environment
- Dynamic environment
- Language manager
- Redirector
- HTML