Link to home
Start Free TrialLog in
Avatar of assaultkitty
assaultkitty

asked on

Walkthrough - using a Configuration File to Define a Data Source

Dear Sirs:  I am working on a Walkthrough: Using a Configuration file to define a Data Source.  I have errors on MyTestMethod and MyTestMethod2 tests.  This is a lab2 presentation that I must make.  It is classwork.  Is it possible to help me with.  I do not understand what the issues are with context and the arrays.  Can you help me?  I am using Microsoft Visual Studio.


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="microsoft.visualstudio.testtools" type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
  </configSections>
  <connectionStrings>
    <add name="MyJetConn" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:Libraries\Documents\testdatasource.accdb; Persist Security Info=False;" providerName="System.Data.OleDb" />
    <add name="MyExcelConn" connectionString="Dsn=Excel Files;dbq=Libraries\Documents\data.xlsx;defaultdir=.; driverid=790;maxbuffersize=2048;pagetimeout=5" providerName="System.Data.Odbc" />
  </connectionStrings>
  <microsoft.visualstudio.testtools>
    <dataSources>
      <add name="MyJetDataSource" connectionString="MyJetConn" dataTableName="MyDataTable" dataAccessMethod="Sequential"/>
      <add name="MyExcelDataSource" connectionString="MyExcelConn" dataTableName="Sheet1$" dataAccessMethod="Sequential"/>
    </dataSources>
  </microsoft.visualstudio.testtools>
</configuration>
 

public class UnitTest1
    {
        private TestContext context;

        public TestContext TestContext
        {
            get { return context; }
            set { context = value; }
        }

        [TestMethod()]
        [DeploymentItem("MyTestProject\\testdatasource.accdb")]
        [DataSource("MyJetDataSource")]
        public void MyTestMethod()
        {
            int a = Int32.Parse(context.DataRow["Arg1"].ToString());
            int b = Int32.Parse(context.DataRow["Arg2"].ToString());
            Assert.AreNotEqual(a, b, "A value was equal.");
        }

        [TestMethod()]
        [DeploymentItem("MyTestProject\\data.xlsx")]
        [DataSource("MyExcelDataSource")]
        public void MyTestMethod2()
        {
            Assert.AreEqual(context.DataRow["Val1"], context.DataRow["Val2"]);
        }
    }
}
 MyTestMethod errors

Error      13      The type 'System.Data.DataRow' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.      C:\Users\acer\Documents\Bank-Blackboard\Bank\TestProject2\UnitTest1.cs      22      13      TestProject2
Error      14      Cannot apply indexing with [] to an expression of type 'System.Data.DataRow'      C:\Users\acer\Documents\Bank-Blackboard\Bank\TestProject2\UnitTest1.cs      22      33      TestProject2
Error      15      Cannot apply indexing with [] to an expression of type 'System.Data.DataRow'      C:\Users\acer\Documents\Bank-Blackboard\Bank\TestProject2\UnitTest1.cs      23      33      TestProject2
Error      16      Cannot apply indexing with [] to an expression of type 'System.Data.DataRow'      C:\Users\acer\Documents\Bank-Blackboard\Bank\TestProject2\UnitTest1.cs      32      29      TestProject2
Error      17      Cannot apply indexing with [] to an expression of type 'System.Data.DataRow'      C:\Users\acer\Documents\Bank-Blackboard\Bank\TestProject2\UnitTest1.cs      32      54      TestProject2


MyTestMethod2 errors

Error      13      The type 'System.Data.DataRow' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.      C:\Users\acer\Documents\Bank-Blackboard\Bank\TestProject2\UnitTest1.cs      22      13      TestProject2
Error      14      Cannot apply indexing with [] to an expression of type 'System.Data.DataRow'      C:\Users\acer\Documents\Bank-Blackboard\Bank\TestProject2\UnitTest1.cs      22      33      TestProject2
Error      15      Cannot apply indexing with [] to an expression of type 'System.Data.DataRow'      C:\Users\acer\Documents\Bank-Blackboard\Bank\TestProject2\UnitTest1.cs      23      33      TestProject2
Error      16      Cannot apply indexing with [] to an expression of type 'System.Data.DataRow'      C:\Users\acer\Documents\Bank-Blackboard\Bank\TestProject2\UnitTest1.cs      32      29      TestProject2
Error      17      Cannot apply indexing with [] to an expression of type 'System.Data.DataRow'      C:\Users\acer\Documents\Bank-Blackboard\Bank\TestProject2\UnitTest1.cs      32      54      TestProject2
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Do you understand the nature of this error?

The type 'System.Data.DataRow' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

Do you know how to add references to a project?
Avatar of assaultkitty
assaultkitty

ASKER

No.  Can you explain?  I am being with C# and I am having a lot of difficulty.  Please elaborate. Thank you.
Right-click on a project in the Solution Explorer, and select Add Reference.  On the .NET tab, you should look for the System.Data.dll, select the entry, and select Add.  

The specific steps may vary depending on the Add Reference dialog that you are using.
I have added a reference.  Now, what do I do.  I need a little explanation.  I guess this is going to take alot of troubleshooting.
After you add the reference, that error should go away.  Then, you need to address the other references.  Sometimes, when you are missing a reference, you can get a lot of cascading errors resulting from that missing reference.  It is a good practice to clear up those types of errors, before you continue on with the next set, so that you don't waste time trying to figure out why they are happening.

The compiler errors reference a file, line number, and column.  Since I can't see the line numbers, you will need to take a compiler error, and show me the corresponding line.  You should be able to double-click on the compiler error in the Error List, and it should take you to the corresponding line in the associated file.
I have added the reference.  I still have the same problem.  Where do we go from here?
int a = Int32.Parse(context.DataRow["Arg1"].ToString());


Error number one.

Error      1      The type 'System.Data.DataRow' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.      C:\Users\Administrator\Documents\Attachments_2012_03_20\Bank_Blackboard\Bank_Blackboard\Bank\TestProject2\UnitTest1.cs      22      13      TestProject2
Error two

int a = Int32.Parse(context.DataRow["Arg1"].ToString());
int b = Int32.Parse(context.DataRow["Arg2"].ToString());

Error      2      Cannot apply indexing with [] to an expression of type 'System.Data.DataRow'      C:\Users\Administrator\Documents\Attachments_2012_03_20\Bank_Blackboard\Bank_Blackboard\Bank\TestProject2\UnitTest1.cs      22      33      TestProject2
Error      3      Cannot apply indexing with [] to an expression of type 'System.Data.DataRow'      C:\Users\Administrator\Documents\Attachments_2012_03_20\Bank_Blackboard\Bank_Blackboard\Bank\TestProject2\UnitTest1.cs      23      33      TestProject2

All of the context variable are highlighted.
TestProject1 -> C:\Users\Administrator\Documents\Attachments_2012_03_20\Bank_Blackboard\Bank_Blackboard\Bank\TestProject1\bin\Debug\TestProject1.dll
------ Rebuild All started: Project: TestProject2, Configuration: Debug Any CPU ------
C:\Users\Administrator\Documents\Attachments_2012_03_20\Bank_Blackboard\Bank_Blackboard\Bank\TestProject2\UnitTest1.cs(22,13): error CS0012: The type 'System.Data.DataRow' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
C:\Users\Administrator\Documents\Attachments_2012_03_20\Bank_Blackboard\Bank_Blackboard\Bank\TestProject2\UnitTest1.cs(22,33): error CS0021: Cannot apply indexing with [] to an expression of type 'System.Data.DataRow'
C:\Users\Administrator\Documents\Attachments_2012_03_20\Bank_Blackboard\Bank_Blackboard\Bank\TestProject2\UnitTest1.cs(23,33): error CS0021: Cannot apply indexing with [] to an expression of type 'System.Data.DataRow'
C:\Users\Administrator\Documents\Attachments_2012_03_20\Bank_Blackboard\Bank_Blackboard\Bank\TestProject2\UnitTest1.cs(32,29): error CS0021: Cannot apply indexing with [] to an expression of type 'System.Data.DataRow'
C:\Users\Administrator\Documents\Attachments_2012_03_20\Bank_Blackboard\Bank_Blackboard\Bank\TestProject2\UnitTest1.cs(32,54): error CS0021: Cannot apply indexing with [] to an expression of type 'System.Data.DataRow'

This is the output.
These are the errors.  I hope this helps.
Errors.docx
Fixed error number one added a reference to the Bank, TestProject1, and TestProject2.  Have four errors.
Thanks you are great!  I do not have anymore errors.  I did not know how to add the system.data reference.  No more errors.  I will continue with the project and let you know if I am having anymore problems.
UTA049: TestProject1.UnitTest1.MyTestMethod has invalid DataSource attribute. Either DataSourceSettingName or ConnectionString and TableName must be specified and cannot be empty.

UTA049: TestProject1.UnitTest1.MyTestMethod2 has invalid DataSource attribute. Either DataSourceSettingName or ConnectionString and TableName

I have these errors after adding the connection string to the my unit test.  I am sending a copy of my Unit test.

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace TestProject1
{
    [TestClass]
    public class UnitTest1
    {
        private TestContext context;

        public TestContext TestContext
        {
            get { return context; }
            set { context = value; }
        }

        [DeploymentItem("MyTestProject\\testdatasource.accdb"), DeploymentItem("TestProject2\\testdatasource.laccdb"), DeploymentItem("TestProject2\\data.xlsx"), TestMethod()]
        [DataSource("System.Data.OleDb", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\testdatasource.laccdb;Jet OLEDB:Database Password=P@ssw)rd", "", DataAccessMethod.Sequential)]
        public void MyTestMethod()
        {
            int a = Int32.Parse(context.DataRow["Arg1"].ToString());
            int b = Int32.Parse(context.DataRow["Arg2"].ToString());
            Assert.AreNotEqual(a, b, "A value was equal.");
        }

        [DeploymentItem("MyTestProject\\data.xlsx"), DeploymentItem("TestProject2\\testdatasource.laccdb"), TestMethod()]
        [DataSource("System.Data.OleDb", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\testdatasource.laccdb;Persist Security Info=True;Jet OLEDB:Database Password=P@ssw0rd", "", DataAccessMethod.Sequential)]
        public void MyTestMethod2()
        {
            Assert.AreEqual(context.DataRow["Val1"], context.DataRow["Val2"]);
        }
    }
You are using this constructor form for the DataSourceAttribute:

DataSourceAttribute Class
http://msdn.microsoft.com/en-us/library/ms243384.aspx

providerInvariantName
Type: System.String
Invariant data provider name, such as System.Data.SqlClient.

connectionString
Type: System.String
A data provider-specific connection string.

tableName
Type: System.String
The name of the data table.

dataAccessMethod
Type: Microsoft.VisualStudio.TestTools.UnitTesting.DataAccessMethod
Specifies the order to access data. It takes a DataAccessMethod.

Look at the arguments that you are specifying for the DataSource attribute, and match them up to the parameters shown above, and see if you can't find a reason for that error.
http://msdn.microsoft.com/en-us/library/ms182527(v=VS.90).aspx
I am using this to determine the data source for the app.config file in my bank.

 <?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="microsoft.visualstudio.testtools" type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
  </configSections>
  <connectionStrings>
    <add name="MyJetConn" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\testdatasource.accdb; Persist Security Info=False;" providerName="System.Data.OleDb" />
    <add name="MyExcelConn" connectionString="Dsn=Excel Files;dbq=C:data.xlsx;defaultdir=.; driverid=790;maxbuffersize=2048;pagetimeout=5" providerName="System.Data.Odbc" />
  </connectionStrings>
  <microsoft.visualstudio.testtools>
    <dataSources>
      <add name="MyJetDataSource" connectionString="MyJetConn" dataTableName="MyDataTable" dataAccessMethod="Sequential"/>
      <add name="MyExcelDataSource" connectionString="MyExcelConn" dataTableName="Sheet1$" dataAccessMethod="Sequential"/>
    </dataSources>
  </microsoft.visualstudio.testtools>
</configuration>

using BankAccountNS;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace TestProject1
{
   
   
    /// <summary>
    ///This is a test class for BankAccountTest and is intended
    ///to contain all BankAccountTest Unit Tests
    ///</summary>
    [TestClass()]
    public class BankAccountTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for Debit
        ///</summary>
        [TestMethod()]
        public void DebitTest()
        {
            BankAccount target = new BankAccount("Mr. Bryan Walton", 11.99); // TODO: Initialize to an appropriate value
            double amount = 11.22; // TODO: Initialize to an appropriate value
            target.Debit(amount);
            // Assert.Inconclusive("A method that does not return a value cannot be verified.");
            Assert.AreEqual((System.Convert.ToDouble(0.77)), target.Balance, 0.05);
        }

        /// <summary>
        ///A test for Credit
        ///</summary>
        [TestMethod()]
        public void CreditTest()
        {
            BankAccount target = new BankAccount("Mr. Bryan Walton", 11.99); // TODO: Initialize to an appropriate value
            double amount = 0F; // TODO: Initialize to an appropriate value
            target.Credit(amount);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

        /// <summary>
        ///A test for FreezeAccount
        ///</summary>
        [TestMethod()]
        [DeploymentItem("Bank.dll")]
        public void FreezeAccountTest()
        {
            BankAccount_Accessor target = new BankAccount_Accessor("Mr. Bryan Walton", 11.99); // TODO: Initialize to an appropriate value
            target.FreezeAccount();
            // Assert.Inconclusive("A method that does not return a value cannot be verified.");

            bool creditAccount = false; // False means account could be credited: Fail test.
            // Try to credit account
            try
            {
                target.Credit(1.00);
            }
            catch (System.Exception)
            {
                // Threw exception. FreezeAccount worked correctly: Pass test.
                creditAccount = true;
            }

            // Assert fails if 'creditAccount' condition is false. Fail test.
            Assert.IsTrue(creditAccount, "Was able to credit account.");
        }


        /// <summary>
        ///A test for FreezeAccount
        ///</summary>
        [TestMethod()]
        [DeploymentItem("Bank.dll")]
        public void FreezeAccountTest1()
        {
            BankAccount_Accessor target = new BankAccount_Accessor(); // TODO: Initialize to an appropriate value
            target.FreezeAccount();
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

        /// <summary>
        ///A test for UnfreezeAccount
        ///</summary>
        [TestMethod()]
        [DeploymentItem("Bank.dll")]
        public void UnfreezeAccountTest()
        {
            BankAccount_Accessor target = new BankAccount_Accessor("Mr. Bryan Walton", 11.99); // TODO: Initialize to an appropriate value
            target.UnfreezeAccount();
            // Assert.Inconclusive("A method that does not return a value cannot be verified.");

            bool creditAccount = true; // True means account could not be credited: Fail test.
            // Try to credit account
            try
            {
                target.Credit(1.00);
            }
            catch (System.Exception)
            {
                // Threw exception. FreezeAccount worked correctly: Pass test.
                creditAccount = false;
            }

            // Assert fails if 'creditAccount' condition is false. Fail test.
            Assert.IsTrue(creditAccount, "Was able to credit account.");
        }

    }
}

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace TestProject1
{
    [TestClass]
    public class UnitTest1
    {
        private TestContext context;

        public TestContext TestContext
        {
            get { return context; }
            set { context = value; }
        }

        [DeploymentItem("MyTestProject\\testdatasource.accdb"), DeploymentItem("TestProject2\\testdatasource.laccdb"), DeploymentItem("TestProject2\\data.xlsx"), TestMethod()]
        [DataSource("System.Data.OleDb", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\testdatasource.laccdb;Jet OLEDB:Database Password=P@ssw)rd", "", DataAccessMethod.Sequential)]
        public void MyTestMethod()
        {
            int a = Int32.Parse(context.DataRow["Arg1"].ToString());
            int b = Int32.Parse(context.DataRow["Arg2"].ToString());
            Assert.AreNotEqual(a, b, "A value was equal.");
        }

        [DeploymentItem("MyTestProject\\data.xlsx"), DeploymentItem("TestProject2\\testdatasource.laccdb"), TestMethod()]
        [DataSource("System.Data.OleDb", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\testdatasource.laccdb;Persist Security Info=True;Jet OLEDB:Database Password=P@ssw0rd", "", DataAccessMethod.Sequential)]
        public void MyTestMethod2()
        {
            Assert.AreEqual(context.DataRow["Val1"], context.DataRow["Val2"]);
        }
    }
}

I hope this helps you to help me!
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am not done with this problem.  I have to get some sleep.  I will start work on this problem tomorrow.
I am back and I need help.  I will be in touch soon.  Thanks expert!
configuration string    

add name="MyJetConn" connectionString=""System.Data.OleDb"; Data Source=C:\testdatasource.accdb; Persist Security Info=False;" providerName="System.Data.OleDb" />

Is this your expected result.
Are you still talking about the DataSource attribute?
Thanks for you gentle urging.  I figured out the process.  I was totally off on this project.  I went back and figured out what was wrong with this project.  It had nothing to do with the bank project. It is is just two files.  One DatadrivenTest.cs and UnitTest1.  Once I completed this process. I found that the connection was correct.  Therefore, I needed to run the test on the the first method in the unittest1.  The unittest1 method has thrown an exception.  So, here is the error.  (classmates can stir you in the wrong direction).  The test on the the method failed.  

Unit Test Adapter threw exception:
The type initializer for 'Microsoft.VisualStudio.TestTools.UnitTesting.TestConfiguration' threw an exception.
An error occurred creating the configuration section handler for microsoft.visualstudio.testtools: Could not load file or assembly 'Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. (C:\Users\acer\Documents\Visual Studio 2010\Projects\DataDrivenTest\bin\Debug\DataDrivenTest.DLL.config line 4)
Could not load file or assembly 'Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified..

Here is the code for the unit test and app.configuration file.  I hope I am on the right track this time.

app.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="microsoft.visualstudio.testtools" type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
  </configSections>
  <connectionStrings>
    <add name="MyJetConn" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\testdatasource.accdb; Persist Security Info=False;" providerName="System.Data.OleDb" />
    <add name="MyExcelConn" connectionString="Dsn=Excel Files;dbq=C:\data.xlsx;defaultdir=.; driverid=790;maxbuffersize=2048;pagetimeout=5" providerName="System.Data.Odbc" />
  </connectionStrings>
  <microsoft.visualstudio.testtools>
    <dataSources>
      <add name="MyJetDataSource" connectionString="MyJetConn" dataTableName="MyDataTable" dataAccessMethod="Sequential"/>
      <add name="MyExcelDataSource" connectionString="MyExcelConn" dataTableName="Sheet1$" dataAccessMethod="Sequential"/>
    </dataSources>
  </microsoft.visualstudio.testtools>
</configuration>

Unit test

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace TestProject1
{
    [TestClass]
    public class UnitTest1
    {
        private TestContext context;

        public TestContext TestContext
        {
            get { return context; }
            set { context = value; }
        }

        [TestMethod()]
        [DeploymentItem("MyTestProject\\testdatasource.accdb")]
        [DataSource("MyJetDataSource")]
        public void MyTestMethod()
        {
            int a = Int32.Parse(context.DataRow["Arg1"].ToString());
            int b = Int32.Parse(context.DataRow["Arg2"].ToString());
            Assert.AreNotEqual(a, b, "A value was equal.");
        }

        [TestMethod()]
        [DeploymentItem("MyTestProject\\data.xlsx")]
        [DataSource("MyExcelDataSource")]
        public void MyTestMethod2()
        {
            Assert.AreEqual(context.DataRow["Val1"], context.DataRow["Val2"]);
        }
    }
}

Can you help me with the exception from the run test?
Do you have a reference in the unit test project to your project that you are trying to test (DataDrivenTest.DLL)?
I have added it.  Now I have an error.
error.docx
Sorry. I loaded the Metaload file.  Thanks.
I still have the exception fail after the run test on MyTestMethod()
Dear Expert,

I am spinning my wheels.  I tried what you asked and I have not gotten anywhere.  It does not matter I add reference it seems.  Can you give me some guidance on this project.

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace TestProject1
{
    [TestClass]
    public class UnitTest1
    {
        private TestContext context;

        public TestContext TestContext
        {
            get { return context; }
            set { context = value; }
        }

        [DeploymentItem("testdatasource.laccdb"), DeploymentItem("testdatasource.accdb"), TestMethod()]
        [DataSource("System.Data.OleDb", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"C:\\testdatasource.laccdb", "MyDataTable", DataAccessMethod.Sequential)]
        public void MyTestMethod()
        {
            int a = Int32.Parse(TestContext.DataRow["Arg1"].ToString());
            int b = Int32.Parse(TestContext.DataRow["Arg2"].ToString());
            Assert.AreNotEqual(a, b, "A value was equal.");
        }

        [TestMethod()]
        [DeploymentItem("MyTestProject\\data.xlsx")]
        [DataSource("MyExcelDataSource")]
        public void MyTestMethod2()
        {
            Assert.AreEqual(context.DataRow["Val1"], context.DataRow["Val2"]);
        }
    }
}


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="microsoft.visualstudio.testtools" type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
    <!--<section name="microsoft.visualstudio.testtools" type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />-->
  </configSections>
  <connectionStrings>
    <add name="MyJetConn" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:MyTestProject\testdatasource.accdb; Persist Security Info=False;" providerName="System.Data.OleDb" />
    <add name="MyExcelConn" connectionString="Dsn=Excel Files;dbq=C:\data.xlsx;defaultdir=.; driverid=790;maxbuffersize=2048;pagetimeout=5" providerName="System.Data.Odbc" />
  </connectionStrings>
  <microsoft.visualstudio.testtools>
    <dataSources>
      <add name="MyJetDataSource" connectionString="MyJetConn" dataTableName="MyDataTable" dataAccessMethod="Sequential"/>
      <add name="MyExcelDataSource" connectionString="MyExcelConn" dataTableName="Sheet1$" dataAccessMethod="Sequential"/>
    </dataSources>
  </microsoft.visualstudio.testtools>
</configuration>
Can someone help me with this problem?  It is urgent?  Thank you!
this is the entire project.  It is named datadriventest.  Can someone help me?
Projects.zip
Hi Experts,

I have asked for help more than 12 hours ago.  I have received no response.  Can I get some help?
Projects.zip
There should be an option to Request Attention.  I can't always be available to answer questions (I do have to sleep after all).
What version of Visual Studio .NET are you working with?  What is the target framework version for the Unit Test project?
I am working with Visual Studio 2010.  I am using target framework 4.0 from the testproject.
There error states, "Could not load file or assembly 'Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies."

The version for 2010 is 10.0.0.0.

Make sure that you have the proper version referenced in the app.config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="microsoft.visualstudio.testtools" type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
  </configSections>
  <connectionStrings>
<section name="microsoft.visualstudio.testtools" type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

This is the line I already have the Version in there.  OK I am listening.
Are you still getting that error about 8.0.0.0?

If so, please check the file references for the unit test project to make sure that you are referencing the correct version for that assembly.
This is the error I am getting.  I had the correct version from the beginning.  I am running the test for the first method in the Unit test.

The unit test adapter failed to connect to the data source or to read the data. For more information on troubleshooting this error, see "Troubleshooting Data-Driven Unit Tests" (http://go.microsoft.com/fwlink/?LinkId=62412) in the MSDN Library.
Error details: Format of the initialization string does not conform to specification starting at index 33.
Too many problems, so little time...

I believe that error is indicating that your connection string is incorrect for the data source.
I got the connection string directly from

http://msdn.microsoft.com/en-us/library/ms243192.aspx

This is the connectionString can you help me to resolve this problem.  Do you know how to do it? n Walk me through this process.  Please!

<add name="MyJetConn" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:MyTestProject\\testdatasource.accdb; Persist Security Info=False;" providerName="System.Data.OleDb" />
I am trying to pin point my problem.  I hope I am on the right track.  Can you help me to correct this problem?

<add name="MyJetConn" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:MyTestProject\testdatasource.accdb; Persist Security Info=False;" providerName="System.Data.OleDb" />

 [DataSource("System.Data.OleDb", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\testdatasource.accdb","MyDataTable", DataAccessMethod.Sequential)]
Those are not valid file names for the Data Source values.
Ok what are the valid file names?  Can you show me why they are not valid?
Remember I am not an expert.  Please explain to me.  I have done the program thus far.  I do not think you will be giving me the answer.  You are too vague.
C:MyTestProject\testdatasource.accdb
C:\\testdatasource.accdb

The back slashes are in the wrong place.