I think I've found a bug. This worked in 5.3.1 but it doesn't anymore in 5.3.4
Perhaps it's the other way around ;)
Here's the code under test:
public class CompanyControlViewPresenter : ContentPresenter<ICompanyControlView>
{
public override void OnViewInitialized()
{
View.Project = this.Project;
View.CompanyViewInfo = GetCompanyViewInfo(View.CompanyID);
}
protected CompanyViewInfo GetCompanyViewInfo(Int32 companyid)
{
return CompanyViewInfo.GetByCompanyId(companyid, SellusContext2.Current.Project.ProjectID, CultureInfo.CurrentUICulture);
}
}
Here's the test initialize, you probably should not worry about faking the HttpContext and SellusContext2 classes.
private ICompanyControlView _fakeViewMock;
[TestInitialize]
public void TestInitialization()
{
Isolate.Fake.StaticMethods<HttpContext>(Members.ReturnRecursiveFakes);
Isolate.Fake.StaticMethods<SellusContext2>(Members.ReturnRecursiveFakes);
_fakeViewMock = Isolate.Fake.Instance<ICompanyControlView>();
}
Here's the test code. As said, it now fails under 5.3.4
[TestMethod]
public void Does_SetProject_When_CallingOnViewInitialized()
{
// Arrange
Isolate.WhenCalled(() => CompanyViewInfo.GetByCompanyId(0, 0, null)).WillReturn(null);
ProjectDefinition p = new ProjectDefinition();
// Act
CompanyControlViewPresenter x = new CompanyControlViewPresenter();
x.Project = p;
x.View = _fakeViewMock;
x.OnViewInitialized();
// Assert
Isolate.Verify.WasCalledWithExactArguments(() => _fakeViewMock.Project = p);
}