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
  1. Home
  2. General Programming
  3. C#
  4. How to unit test this method

How to unit test this method

Scheduled Pinned Locked Moved C#
questionvisual-studiohardwaretestinghelp
1 Posts 1 Posters 0 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.
  • C Offline
    C Offline
    chuckdawit
    wrote on last edited by
    #1

    Say I create a unit test that looks something like this below (autogenerated by VS) to test: [TestMethod()] public void UniContexPipeDataTest() { IResponse response = null; // TODO: Initialize to an appropriate value ISeries series = null; // TODO: Initialize to an appropriate value DateTime asof = new DateTime(); // TODO: Initialize to an appropriate value UniContext target = new UniContext(response, series, asof); target.PipeData(); Assert.Inconclusive("TODO: Implement code to verify target"); } I know I have to initialize response and series but they are big and have lots of other objects and Interfaces embedded within them that need to be instantiated for the UniContext contructor and PipeData() to work correctly. Q. How do I get the interfaces ready so that the constructor and method PipeData() pass in this unit test? Right now I can create these objects and interfaces to pass into the target but they will be empty. Both IResponse and ISeries have tons of embedded interfaces and other things like other objects and properties inside them that need to be created and instantiated with data. Do I need to start with the embedded object first and then do a ordered test unit test type deal? Do I need to learn about stubs, external dependencies and creating mocks objects? Any help/advice on this will be appreciated. --------------------------------------------------------------------------------

    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