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

  • Home
  • SEARCH
  • 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 7933859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:27:28+00:00 2026-06-03T21:27:28+00:00

I’m doing coded ui testing, basically unit testing for the ui, and I have

  • 0

I’m doing coded ui testing, basically unit testing for the ui, and I have created a TestObject class that stores a list of assertions to be performed against itself within the TestMethod that instantiates it.

public class TestObject {
    public string urlToTest;
    public List<Assertion> assertions;
}

public class Assertion {
    public List<SearchPropertyExpression> searchPropertyExpressions;
    public Action assertMethod;
    public string expectedValue; // <-- this works fine if I'll always call a method like AreEqual() where it has an expected value, but what if I want to store a method in assertMethod that has different arguments???
}

public class SearchPropertyExpression {
    public string expression;
    public string value;
}

I would like to store the assert method (for example: Assert.AreEqaul(object expected, object actual) that I want executed against that particular TestObject and call that later but I’m struggling to get something that is syntactically correct. I’m also struggling with how to pass the arguments for that delegate method (assertMethod) when it’s actually called. All methods that I’ll be calling are within Microsoft.VisualStudio.TestTools.UnitTesting.Assert. In the example below I would like to call Assert.AreEqaul() but any method with varying arguments could be called. Here’s what I’ve got so far…

[TestMethod]
public void uiTestConnectionsEducationHomePage() {
    //instantiate test object
    TestObject testObject = new TestObject() {
        urlToTest = "/example/home.aspx",
        assertions = {
            new Assertion() {
                searchPropertyExpressions = {
                    new SearchPropertyExpression() {
                        expression = HtmlDiv.PropertyNames.Id,
                        value = "header"
                    }
                },
                assertMethod = Assert.AreEqual // <-- this is wrong,I'm thinking I need to tell assertMethod what arguments to expect here, lambda??
            }
        }
    };

    // get handle to browser and launch
    UiBrowserWindow uiBrowserWindow = new UiBrowserWindow();
    uiBrowserWindow.launchUrl(testObject.urlToTest);

    // assertions
    testObject.assertions.ForEach(x => {
        HtmlDiv htmlObject = new HtmlDiv();
        x.searchPropertyExpressions.ForEach(p => {
            htmlObject = uiBrowserWindow.uiHtmlDocument.searchHtmlElementByAttributeValue<HtmlDiv>(p.expression, p.value);
        });
        x.assertMethod; // <-- for this is example the arguments would be (htmlObject, "header").                   
    });
}

I think my real problem is that there is a design pattern here that could really help me but I’m not well versed in design patterns.

  • 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-06-03T21:27:29+00:00Added an answer on June 3, 2026 at 9:27 pm

    Your assertMethod delegate is of type Action which represents a method with a return type of void and no parameters, e.g. void Foo().
    Assert.AreEqual has many overloads, the most universial being Assert.AreEqual(Object expected, Object actual). I suggest you use this and change your delegate accordingly:

    Action<Object, Object> assertMethod;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing a simple coin flipping experiment for class that involves flipping a
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,

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.