Mocking User.Identity.Name

One of the other issue you might encounter while unit testing your Controller is when you dealing with Identity. Consider the following action method. public async Task<BarResponse> Foo(BarRequest user) { if (ModelState.IsValid) { try { var userName = User.Identity.Name; // Do Task return new BarResponse{ }; } catch (Exception ex) { return new BarResponse { … Continue reading Mocking User.Identity.Name