-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Conversation
NancyModule.ViewRenderer View { get; } | ||
|
||
/// <summary> | ||
/// Used to nedotiate the content returned based on Accepts header. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Negotiate is spelled wrong
Hi guys, I'm out of league here with trying to help resolve this issue - especially since I sorta raised this issue. What I've got here are some real test code which I think might help highlight the problem more. I know you guys know what's going on .. but I feel that if I can provide you with some use-case tests .. it might help in some way. To start off, this code is from my new Here's the interface signature:
Notice how I'm passing in an Now - lets see some test code which i would like to have ... [Fact(Skip = "TODO")]
public void GivenAnAuthenticatedClientAndNoReturnUrl_Process_ReturnsAView()
{
// Arrange.
var nancyModule = A.Fake<INancyModule>();
var accessToken = new AccessToken(...);
var userInformation = new UserInformation(...);
var authenticationProviderCallback = new FakeAuthenticationProviderCallback();
var authenticationCallbackResult = new AuthenticateCallbackResult
{
AuthenticatedClient = new AuthenticatedClient("Google",
accessToken,
userInformation,
"some raw info goes here pew pew pew")
};
// Act.
var result = authenticationProviderCallback.Process(nancyModule, authenticationCallbackResult);
// Assert.
// Not sure how to do this yet.
} So pretty simple so far... but we need some context .. so .. for it's time for the money shot ... public dynamic Process(INancyModule nancyModule, AuthenticateCallbackResult result)
{
var model = new UserViewModel
{
Name = result.AuthenticatedClient.UserInformation.Name,
Email = result.AuthenticatedClient.UserInformation.Email
};
// User cancelled during the Authentication process?
if (result.AuthenticatedClient == null)
{
return nancyModule.Response.AsRedirect(result.ReturnUrl,
RedirectResponse.RedirectType.Temporary);
}
// We have a user, so lets do something with their data :)
if (string.IsNullOrWhiteSpace(result.ReturnUrl))
{
return nancyModule.Response.View[model];
}
return nancyModule.Response.AsRedirect(result.ReturnUrl);
} It's a pretty simplistic and contrite example, but this is a unit test after all.
And there is no View property on the current interface. So yeah - I totally get that you guys know all this .. I just thought that by adding some code examples it might give some other clarity or help to the problem. And right now - I can't go on until this is resolved 😢 |
3935146
to
ec65ae3
Compare
@NancyFx/most-valued-minions Ok this is ready to be pulled. @PureKrome when this is in the next release (or CI builds) you can do:
|
Superseeds PR #1472
Add's missing XML Comment and moves View/Negotiate to the
INancyModule
This allows the module to be mocked for use in 3rd party app testing.
i.e in SimpleAuthentication library we have an
IAuthenticationProviderCallback
class which has the module passed into, however this cannot be tested without attempting to mock the entire NancyModule.