Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. How to test Web Methods with NUnit

How to test Web Methods with NUnit

Scheduled Pinned Locked Moved C#
csharphelpdatabasebusinesssales
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Phillip Donegan
    wrote on last edited by
    #1

    Hi all, In my solution I already have lots of business object unit tests. However I also want to test the web service layer. So to do this I've added another project to the solution and added a project reference to the web service layer. So now I can see all the web methods. The problem I have is that when I want to go to the database my method GetDAOFactory() always returns null. I think this is because the global file inherits the HttpApplication class. E.G. Try and get the customer or create a new one 1) private Customer GetCustomerInSession() { Customer customer = Session[PropertyCustomer] as Customer; if (customer == null) { Session[PropertyCustomer] = customer = new Customer(GetDAOFactory()); } return customer; } Get the DAO Factory this returns null 2) private IDAOFactory GetDAOFactory() { return Application[Global.DAOFactorySetting] as IDAOFactory; } I think the reason is because global inherits HttpApplication 3) public class Global : HttpApplication { protected void Application_Start(object sender, EventArgs e) { // create data access implementation string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["DevBox"].ConnectionString; Application[DAOFactorySetting] = new ADODAOFactory(ProviderType.SqlServer, connectionString); } protected void Application_End(object sender, EventArgs e) { } public static readonly string DAOFactorySetting = "DAOFactory"; } Any ideas why its returning null? I've thought of one solution and that would be to change the reference to a web reference. The only problem then is that I would either have to add a localhost web reference which wouldn't work with the CI build. Or to reference the published development app layer, but that would mean that when I change my code I wouldn't be able to test it until it was committed!! Any help would be greatly appreciated. I'm using C#.Net 2.0 with NUnit 2.4.7 Phil P.S. I've copied the connectionString DevBox to the App.config in the WebServiceTests project so that it can see it.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups