Member-only story
Getting started with Unit Testing and Moq — Part 4
In the previous post, we had setup our basic WCF project to play around with for unit testing. Since then, I have pulled out the WCF service reference in the console application, and placed it in our business project. Now that the business project has the WCF service reference, I have added a new class that handles the newing up of the WCF client.
Additionally, I have updated the console application to use the new business object wrapper of the WCF client. Both of those classes look like this: Program.cs
namespace RussUnitTestSample
{
class Program
{
#region consts
const string CONNECTION_STRING = "Data Source=192.168.50.4,1515;Initial Catalog=MBES;Persist Security Info=True;Integrated Security=true;";
#endregion consts
#region Entry
static void Main(string[] args)
{
GetNumbersAndAddThem obj = new GetNumbersAndAddThem(
new DbGetSomeNumbers(new BaseDbConnection(CONNECTION_STRING)),
new NumberFunctions()
);
Console.WriteLine("\n");
Console.WriteLine(obj.Execute());
Console.WriteLine("\n");
Business.WCF.Service1 service = new Business.WCF.Service1();
Console.WriteLine("\n");
Console.WriteLine("{0}", service.GetData(42));
Console.WriteLine("\n");
}
#endregion Entry
}
}
WCF.Service1
namespace RussUnitTestSample.Business.WCF
{
/// <summary>
/// Communication with the…