Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7443315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:18:42+00:00 2026-05-29T11:18:42+00:00

I am designing a test application (Using NUnit) that will have to navigate (through

  • 0

I am designing a test application (Using NUnit) that will have to navigate (through Selenium Webdriver API) through webpages. I’d like to modelize the site structure using enums to be able to tell methods where to navigate (especially NUnit methods) via this enum.

this.NavigateTo(Page.HomePage);

This is a strong requirement (to have an enum type somewhere) mostly because NUnit cannot be passed non-primitive types. For instance, this syntax is impossible to NUnit because Page has to be primitive or enum:

static class Page{
  public static Page HomePage;
  public static Page UserAccountPage;
}

/* ... later ... */
[TestCase(Page.HomePage)]
void TestMethod(Page p) { ...

I’d also like to use the same enum-or-the-like to make basic inheritance, like

interface IPage{}
interface IPageNavigatable : Page {}
interface IPageUserRelated : Page {}
interface IWildcardPage : Page {}

enum Page{
  HomePage : IPageNavigatable,
  UserAccountPage : IPageNavigatable IPageUserRelated,
  ErrorPage : /* none */,
  AnyPage : IWildcardPage 
}

And then, I would be able to make very fun methods like

bool IsCurrentPage(IWildcardPage p);
void LoginThenNavigate(String user, String pw, IPageUserRelated p);
Page WhereAmI(); /* and use this value with IsAssignableFrom */

I know C# forbids enum inheritance (I still don’t understand this choice but this is not my question now) and I’ve read a few workarounds, including a class that recodes from scratch the enum mechanism; and none looks satisfactory.

The best Idea I have is using a complex class with an inner enum and a few public booleans. Not very satisfctory…

public class Page{
  enum Pages { /* you know them */}
  public Page.Pages InnerPage;
  public bool isWildcard, isUserRelated, ...;

  public Page(Page.Pages p){
    this.InnerPage = p;
    switch (p){
      case ...:
      case ...:
        this.isWildcard = true;
        break;
      /* ... */
    }
  }
}

/* NUnit calls */
[TestCase(Page.Pages.HomePage)]
void TestMethod(Page.Pages p) { ...

Also, in a perfect world, I’d love to “link” my enum-or-so typed values with Strings or URIs, so that I could write something like:

enum Page{
  HomePage : IPageNavigatable = "/index.php",
  UserAccountPage : IPageNavigatable IPageUserRelated = "/user.php",
  ErrorPage : /* none */ = (String) null,
  AnyPage : IWildcardPage = (String) null
}

/* ... */
Page p;
Selenium.Webdriver drv;
drv.Navigate().GoToUrl(new Url(p.ToString()));

This is a tough problem to me. Anyone can help?

EDIT: A clue, as Chris points out below, is that NUnit (through attributes) can take an argument of type Object. Using this, there is probably a way to implement nearly-no-code objects with my inheritance structure, and recode part of the enum mechanism (and link to the URL strings).

Not my dream solution but might work…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:18:43+00:00Added an answer on May 29, 2026 at 11:18 am

    Are you sure that they must be primitives (by the way, we call those Value Types or structs in the .net world)? This page seems to imply that the reason that you are limited is because of the inherent limitations in .NET attributes, which in turn are described here:

    Attribute parameters are restricted to constant values of the
    following types:

    Simple types (bool, byte, char, short, int, long, float, and double)

    string

    System.Type

    enums

    object (The argument to an attribute parameter of type object must be a constant value of one of the above types.)

    One-dimensional arrays of any of the above types

    This suggests to me that the following would work:

    static class Pages {
      public const String HomePage = "Home Page";
      public const String UserAccountPage = "User Account Page";
    }
    
    [TestCase(Pages.HomePage)]
    void TestMethod(Page p) { ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a unique issue - I am designing a web application that creates
I have a strange observation that in any web application designing, why we need
I'm currently in the early stages of designing a system that will end up
Like the title says, should I still be designing my application around a 16
I am running an Integration Test for a Grails application. I am using the
I'm designing an application that need to extract people's names from short texts. What
So I'm not very good with C but I'm designing a GLUT application that
A number of developers are designing their applications using Test Driven Development (TDD) but
I wrote a flex application that get the host string from the browser using
I am designing an application using sockets to connect to each other over the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.