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. C# Attributes

C# Attributes

Scheduled Pinned Locked Moved C#
questioncsharpcomtestingworkspace
2 Posts 2 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.
  • J Offline
    J Offline
    jeramyRR
    wrote on last edited by
    #1

    Hi all, I was just reading the following article Introduction to NUnit... and was introduced to Attributes. I'm a noob so I've never seen this before or read about it. I understand that it allows you to define metadata within your program and so on... My question is more so about format than understanding. I was wondering if I put in an attribute right above on function if that attribute is assigned to all functions below it until another attribute is reached. For instance:

    [SetUp]
    public void init()
    {
    Person person = new Person();
    }

    public void foo()
    {...}

    Will the attribute [SetUp] be for both init and foo, or just init? Thanks, Jeramy

    B 1 Reply Last reply
    0
    • J jeramyRR

      Hi all, I was just reading the following article Introduction to NUnit... and was introduced to Attributes. I'm a noob so I've never seen this before or read about it. I understand that it allows you to define metadata within your program and so on... My question is more so about format than understanding. I was wondering if I put in an attribute right above on function if that attribute is assigned to all functions below it until another attribute is reached. For instance:

      [SetUp]
      public void init()
      {
      Person person = new Person();
      }

      public void foo()
      {...}

      Will the attribute [SetUp] be for both init and foo, or just init? Thanks, Jeramy

      B Offline
      B Offline
      Bernhard Hiller
      wrote on last edited by
      #2

      The [SetUp] attribute was placed above init - consequently, only the function init has that attribute. By the way, with NUnit, you need a [TestFixture] above your class declarartion, a [TestFixtureSetUp] for the test setup method (if availbale), and a [Test] for every actual test method - the attributes differ between Microsoft Test and NUnit. You can use Visual NUnit for running your tests from Visual Studio (has some bugs, but it's still easier than using the NUnit GUI).

      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