Skip to main content
deleted 2 characters in body
Source Link
Josh
  • 8.6k
  • 14
  • 81
  • 126

Background:

I'm testing a function within an ASP.NET 4.0 (Web Forms not MVC) and I'm using Unit Testing built into Visual Studio 2010. I've created a separate test project and creating a test class for each class in the web project.

Question:

I've run into an issue with one of the functions that uses HttpContext.Current.User.Identity.Name as part of the logic. How do set that value in the Unit testing project class or method so that I can test that function?

** Update **Update:

What I was hoping for was that there was additional attribute I could set above my test method. Currently I have:

[TestMethod()] [HostType("ASP.NET")] [AspNetDevelopmentServerHost("C:\\DEV\\ProjectName\\ClientWeb", "/")] [UrlToTest("http://localhost:9018/")] public void GetLoginTest() { // test code } 

Background:

I'm testing a function within an ASP.NET 4.0 (Web Forms not MVC) and I'm using Unit Testing built into Visual Studio 2010. I've created a separate test project and creating a test class for each class in the web project.

Question:

I've run into an issue with one of the functions that uses HttpContext.Current.User.Identity.Name as part of the logic. How do set that value in the Unit testing project class or method so that I can test that function?

** Update **

What I was hoping for was that there was additional attribute I could set above my test method. Currently I have:

[TestMethod()] [HostType("ASP.NET")] [AspNetDevelopmentServerHost("C:\\DEV\\ProjectName\\ClientWeb", "/")] [UrlToTest("http://localhost:9018/")] public void GetLoginTest() { // test code } 

Background:

I'm testing a function within an ASP.NET 4.0 (Web Forms not MVC) and I'm using Unit Testing built into Visual Studio 2010. I've created a separate test project and creating a test class for each class in the web project.

Question:

I've run into an issue with one of the functions that uses HttpContext.Current.User.Identity.Name as part of the logic. How do set that value in the Unit testing project class or method so that I can test that function?

Update:

What I was hoping for was that there was additional attribute I could set above my test method. Currently I have:

[TestMethod()] [HostType("ASP.NET")] [AspNetDevelopmentServerHost("C:\\DEV\\ProjectName\\ClientWeb", "/")] [UrlToTest("http://localhost:9018/")] public void GetLoginTest() { // test code } 
added 366 characters in body
Source Link
Josh
  • 8.6k
  • 14
  • 81
  • 126

Background:

I'm testing a function within an ASP.NET 4.0 (Web Forms not MVC) and I'm using Unit Testing built into Visual Studio 2010. I've created a separate test project and creating a test class for each class in the web project.

Question:

I've run into an issue with one of the functions that uses HttpContext.Current.User.Identity.Name as part of the logic. How do set that value in the Unit testing project class or method so that I can test that function?

** Update **

What I was hoping for was that there was additional attribute I could set above my test method. Currently I have:

[TestMethod()] [HostType("ASP.NET")] [AspNetDevelopmentServerHost("C:\\DEV\\ProjectName\\ClientWeb", "/")] [UrlToTest("http://localhost:9018/")] public void GetLoginTest() { // test code } 

Background:

I'm testing a function within an ASP.NET 4.0 (Web Forms not MVC) and I'm using Unit Testing built into Visual Studio 2010. I've created a separate test project and creating a test class for each class in the web project.

Question:

I've run into an issue with one of the functions that uses HttpContext.Current.User.Identity.Name as part of the logic. How do set that value in the Unit testing project class or method so that I can test that function?

Background:

I'm testing a function within an ASP.NET 4.0 (Web Forms not MVC) and I'm using Unit Testing built into Visual Studio 2010. I've created a separate test project and creating a test class for each class in the web project.

Question:

I've run into an issue with one of the functions that uses HttpContext.Current.User.Identity.Name as part of the logic. How do set that value in the Unit testing project class or method so that I can test that function?

** Update **

What I was hoping for was that there was additional attribute I could set above my test method. Currently I have:

[TestMethod()] [HostType("ASP.NET")] [AspNetDevelopmentServerHost("C:\\DEV\\ProjectName\\ClientWeb", "/")] [UrlToTest("http://localhost:9018/")] public void GetLoginTest() { // test code } 
Source Link
Josh
  • 8.6k
  • 14
  • 81
  • 126

How set HttpContext.Current.User.Identity.Name for Unit Testing

Background:

I'm testing a function within an ASP.NET 4.0 (Web Forms not MVC) and I'm using Unit Testing built into Visual Studio 2010. I've created a separate test project and creating a test class for each class in the web project.

Question:

I've run into an issue with one of the functions that uses HttpContext.Current.User.Identity.Name as part of the logic. How do set that value in the Unit testing project class or method so that I can test that function?