Windows Server AppFabric / Workflow Services Demo - Contoso HR

This sample demonstrates how you can use a Windows Workflow Foundation (WF4) Workflow Service and Windows Server AppFabric to construct a long running business process.

C# (6.3 MB)
 
 
 
 
 
4.9 Star
(8)
6,145 times
Add to favorites
12/3/2011
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

C#
namespace MathServiceLibrary.Tests
{
    using System.ServiceModel;

    using Microsoft.Activities.UnitTesting;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class IncrementServiceTest
    {
        #region Constants and Fields

        private static readonly EndpointAddress serviceAddress = new EndpointAddress("net.pipe://localhost/IncrementService");

        private static NetNamedPipeBinding binding = new NetNamedPipeBinding();

        #endregion

        #region Properties

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

        #endregion

        #region Public Methods

[TestMethod]
// You must deploy the XAMLX file to the test directory
[DeploymentItem(@"MathServiceLibrary\IncrementService.xamlx")]
public void IncrementServiceShouldIncrementData()
{
    // Arrange
    const int initialData = 1;
    const int expectedData = 2;

    WorkflowServiceTestHost host = null;
    try
    {
        using (host = WorkflowServiceTestHost.Open("IncrementService.xamlx", serviceAddress))
        {
            var proxy = new IncrementService.ServiceClient(binding, serviceAddress);
            int? value = initialData;
            proxy.Increment(ref value);
            Assert.AreEqual(expectedData, value, "Increment did not correctly increment the value");
        }
    }
    finally
    {
        if (host != null)
        {
            host.Tracking.Trace();
        }
    }
}

        #endregion
    }
}