assaultkitty
asked on
Programmer needs help! C#
I am doing a walkthrough with msdn. I need help configuring this file. Can someone help me? This is the DateDrivenTest.cs. This is not an assignment.
using System;
using Microsoft.VisualStudio.Tes tTools.Uni tTesting;
namespace TestProject1
{
[TestClass]
public class UnitTest1
{
private TestContext context;
public TestContext TestContext
{
get { return context; }
set { context = value; }
}
[DeploymentItem("testdatas ource.lacc db"), DeploymentItem("testdataso urce.accdb "), TestMethod()]
[DataSource("System.Data.O leDb", "Provider=Microsoft.Jet.OL EDB.4.0;Da ta Source=\"C:\\testdatasourc e.laccdb", "MyDataTable", DataAccessMethod.Sequentia l)]
public void MyTestMethod()
{
int a = Int32.Parse(TestContext.Da taRow["Arg 1"].ToStri ng());
int b = Int32.Parse(TestContext.Da taRow["Arg 2"].ToStri ng());
Assert.AreNotEqual(a, b, "A value was equal.");
}
[TestMethod()]
[DeploymentItem("MyTestPro ject\\data .xlsx")]
[DataSource("MyExcelDataSo urce")]
public void MyTestMethod2()
{
Assert.AreEqual(context.Da taRow["Val 1"], context.DataRow["Val2"]);
}
}
}
This is the app.config file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="microsoft.visualstud io.testtoo ls" type="Microsoft.VisualStud io.TestToo ls.UnitTes ting.TestC onfigurati onSection, Microsoft.VisualStudio.Qua lityTools. UnitTestFr amework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d 50a3a"/>
<!--<section name="microsoft.visualstud io.testtoo ls" type="Microsoft.VisualStud io.TestToo ls.UnitTes ting.TestC onfigurati onSection, Microsoft.VisualStudio.Qua lityTools. UnitTestFr amework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d 50a3a" />-->
</configSections>
<connectionStrings>
<add name="MyJetConn" connectionString="Provider =Microsoft .Jet.OLEDB .4.0; Data Source=C:MyTestProject\tes tdatasourc e.accdb; Persist Security Info=False;" providerName="System.Data. OleDb" />
<add name="MyExcelConn" connectionString="Dsn=Exce l Files;dbq=C:\data.xlsx;def aultdir=.; driverid=790;maxbuffersize =2048;page timeout=5" providerName="System.Data. Odbc" />
</connectionStrings>
<microsoft.visualstudio.te sttools>
<dataSources>
<add name="MyJetDataSource" connectionString="MyJetCon n" dataTableName="MyDataTable " dataAccessMethod="Sequenti al"/>
<add name="MyExcelDataSource" connectionString="MyExcelC onn" dataTableName="Sheet1$" dataAccessMethod="Sequenti al"/>
</dataSources>
</microsoft.visualstudio.t esttools>
</configuration>
I just need to know how to connect the two files to this program.
Can you help me?
testdatasource.accdb
data.xlsx
using System;
using Microsoft.VisualStudio.Tes
namespace TestProject1
{
[TestClass]
public class UnitTest1
{
private TestContext context;
public TestContext TestContext
{
get { return context; }
set { context = value; }
}
[DeploymentItem("testdatas
[DataSource("System.Data.O
public void MyTestMethod()
{
int a = Int32.Parse(TestContext.Da
int b = Int32.Parse(TestContext.Da
Assert.AreNotEqual(a, b, "A value was equal.");
}
[TestMethod()]
[DeploymentItem("MyTestPro
[DataSource("MyExcelDataSo
public void MyTestMethod2()
{
Assert.AreEqual(context.Da
}
}
}
This is the app.config file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="microsoft.visualstud
<!--<section name="microsoft.visualstud
</configSections>
<connectionStrings>
<add name="MyJetConn" connectionString="Provider
<add name="MyExcelConn" connectionString="Dsn=Exce
</connectionStrings>
<microsoft.visualstudio.te
<dataSources>
<add name="MyJetDataSource" connectionString="MyJetCon
<add name="MyExcelDataSource" connectionString="MyExcelC
</dataSources>
</microsoft.visualstudio.t
</configuration>
I just need to know how to connect the two files to this program.
Can you help me?
testdatasource.accdb
data.xlsx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://msdn.microsoft.com/en-us/vstudio/bb694502.aspx shows you how
ASKER
This is in the unit test.
DataSource("System.Data.Ol eDb", "Provider=Microsoft.Jet.OL EDB.4.0;Da ta Source=\"C:\testdatasource .accdb", "MyDataTable", DataAccessMethod.Sequentia l)]
Can you explain what is wrong with this statement or show me? In the video, he does not show how to connect specifically with is issue. Is the solution?
Data Source="C:testdatasource.a ccb"
or
Data Source=\"C:testdatasource. accb"
or
Data Source="C:MyTestProject\te stdatasour ce.accdb"
I am very new to this programming with C#. So, please talk me through.
DataSource("System.Data.Ol
Can you explain what is wrong with this statement or show me? In the video, he does not show how to connect specifically with is issue. Is the solution?
Data Source="C:testdatasource.a
or
Data Source=\"C:testdatasource.
or
Data Source="C:MyTestProject\te
I am very new to this programming with C#. So, please talk me through.
ASKER
I am trying to pin point my problem. I hope I am on the right track. Can you help me to correct this problem? there is a connection problem so how do I fix this.
app.config
<add name="MyJetConn" connectionString="Provider =Microsoft .Jet.OLEDB .4.0; Data Source=C:MyTestProject\tes tdatasourc e.accdb; Persist Security Info=False;" providerName="System.Data. OleDb" />
unit test
[DataSource("System.Data.O leDb", "Provider=Microsoft.Jet.OL EDB.4.0;Da ta Source=C:\\testdatasource. accdb","My DataTable" , DataAccessMethod.Sequentia l)]
app.config
<add name="MyJetConn" connectionString="Provider
unit test
[DataSource("System.Data.O