When you are developing a DNN module you have access to a bunch of properties in the core framework such as UserID, ModuleID and LocalResourceFile. When you start developing modules using Test Driven Development (TDD) you still need access to these properties which means we need to be able to access them from the presenter class.
The presenter class has a construct like this
Public Sub New(ByVal _View As IViewTestDrivenDNNModule)
View = _View
Controller = New TestDrivenDNNModuleController
which means that the View we access in the presenter class only has the properties specified in the interface for the View. We can access the LocalResourceFile if the DotNetNuke.UI.Modules.IModuleControl is inherited but since the PortalModuleBase class does not have an interface we cannot access the other properties we need.
So I made a few changes to the core to experiment with an Interface for the PortalModuleBase. Firstly I created a new interface called IPortalModuleBase
Public Interface IPortalModuleBase
ReadOnly Property ModuleID() As Integer
ReadOnly Property UserID() As Integer
Then the PortalModuleBase class implements the new interface
Public Class PortalModuleBase
Public ReadOnly Property ModuleId() As Integer Implements IPortalModuleBase.ModuleID
And lastly the interface for our module inherits both of the IPortalModuleBase and IModuleControl interfaces like this
Public Interface IViewTestDrivenDNNModule
This allows easy access to the properties we need in the presenter class like this
colTestDrivenDNNModules = objTestDrivenDNNModules.GetTestDrivenDNNModules(View.ModuleID)
Previously I had just added new properties to the IViewTestDrivenDNNModule interface and pulled the values through from the ViewTestDrivenDNNModule partial class. This however was inelegant and led to having properties such as ModuleId1!! This new solution is far more useable and very easy to implement.
Doing this will allow much easier development of TDD DNN modules.