3

I would like to make use of NUnit's Sequential attribute with arrays.

string[] oldSitesArray = new string[]
    {
        "http://www.LegacySite.com",
        "http://someURLgoeshere.com"
    };

string[] newSitesArray = new string[]
    {
        "http://www.LegacySiteUpdatedURL.com",
        "http://someURLgoeshereUpdatedSite.com"
    };

[Test]
public void keywordsTest()
{
    Assert.IsTrue(this.scc.metaKeywordsChecker(oldSites, newSites));
}

The goal here is to pass in two arrays (using the sequential attribute). One array contains the legacy site URLs, the second array contains the migrated URLs.

The metaKeywordsChecker function takes two Strings. One is the old URL, the other is the updated URL. I have a list of 1,700 URL pairs (array #1 and array #2) that I need to pass into the test sequentially.

1
  • Is the goal to actually use [Sequential] or to compare two arrays? Commented Sep 11, 2012 at 19:08

1 Answer 1

2

Still pretty sure you want the Range attribute.

[Test]
public void keywordsTest([Range(0,1700)] int index)
{
    Assert.IsTrue(this.scc.metaKeywordsChecker(oldSitesArray[index], newSitesArray[index]));
}

Or you could do this...

[Test]
public void keywordsTest()
{
    foreach(var pair in oldSites.Zip(newSites, (o, n) => new {Old = o, New = n}))
    {
         Assert.IsTrue(this.scc.metaKeywordsChecker(pair.Old, pair.New));
    }
}
Sign up to request clarification or add additional context in comments.

1 Comment

Aha! That's genius. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.