public void GeneratesAnApiKey() { var controller = new TestableUsersController(); controller.MockCurrentIdentity .Setup(i => i.Name) .Returns("the-username"); controller.GenerateApiKey(); controller.MockUserService .Verify(s => s.GenerateApiKey("the-username")); }
public void RedirectsToAccountPage() { var controller = new TestableUsersController(); controller.MockCurrentIdentity .Setup(i => i.Name) .Returns("the-username"); var result = controller.GenerateApiKey() as RedirectToRouteResult; Assert.NotNull(result); Assert.Equal("Account", result.RouteValues["action"]); Assert.Equal("Users", result.RouteValues["controller"]); }