We help IT Professionals succeed at work.
Get Started

c# linqToExcel covert to string objects

Last Modified: 2016-01-19
Hi Guys,

I have a NUnit test in which I'm trying to read the testdata from rows in an excel file. My NUnit test is quite simple for this example and is below

 [Test, TestCaseSource("linqTesting2")]
        public void CompleteFormTestDataSource4(String username, String password)

            LoginPageObject pageLogin = new LoginPageObject();
            EAPageObject pageEA = pageLogin.Login(username, password);


Open in new window

My method to read the excel rows using linqToExcel is below

public static IQueryable<LinqToExcel.Row> linqTesting2()
            var excel = new ExcelQueryFactory(Constants.testDataPath4);
            var testcases = from c in excel.Worksheet("Sheet1")
                            where c["UserName"] == "SonjaB"
                            select c;
            return testcases;

Open in new window

To use the row data in my unit test do I need to somehow convert it to a IEnumerable<string[]> before it gets returned to the test. If so any ideas on how to do this would be appreciated. When I ran the test the only error I get is I need to pass the correct amount of parameters.

Watch Question
Most Valuable Expert 2011
Top Expert 2015
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE