Click here to Skip to main content
15,895,746 members
Articles / Programming Languages / C#

Test Driven Prototyping - Learning About .NET Remoting

Rate me:
Please Sign up or sign in to vote.
4.90/5 (25 votes)
7 Apr 200719 min read 69.7K   144   79  
Use test driven development processes to determine the issues affecting application architecture and design with regards to .NET remoting.
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;

using Interfaces;

namespace ClientTests
{
	public static class RemotingHelper
	{
		public static void LoadConfiguration(string configFile)
		{
			RemotingConfiguration.Configure(configFile, false);
		}

		public static void UnloadConfiguration()
		{
			IChannel[] channels=ChannelServices.RegisteredChannels;

			foreach (IChannel channel in channels)
			{
				ChannelServices.UnregisterChannel(channel);
			}
		}

		public static ITest CreatePerCallTestObject()
		{
			MarshalByRefObject objRef = (MarshalByRefObject)RemotingServices.Connect(typeof(ITest), "http://localhost:65100/SingleCallTestService");
			ITest test = objRef as ITest;

			return test;
		}

		public static ITest CreateSingletonTestObject()
		{
			MarshalByRefObject objRef = (MarshalByRefObject)RemotingServices.Connect(typeof(ITest), "http://localhost:65100/SingletonTestService");
			ITest test = objRef as ITest;

			return test;
		}

		public static IFactory CreateFactoryObject()
		{
			MarshalByRefObject objRef = (MarshalByRefObject)RemotingServices.Connect(typeof(IFactory), "http://localhost:65100/FactoryService");
			IFactory factory = objRef as IFactory;

			return factory;
		}

		public static IAsyncManagement CreateAsyncManagement()
		{
			MarshalByRefObject objRef = (MarshalByRefObject)RemotingServices.Connect(typeof(IFactory), "http://localhost:65100/AsyncThreadService");
			IAsyncManagement asyncMgr = objRef as IAsyncManagement;

			return asyncMgr;
		}

		public static IComplexTest CreateComplexTest()
		{
			MarshalByRefObject objRef = (MarshalByRefObject)RemotingServices.Connect(typeof(IFactory), "http://localhost:65100/ComplexTestService");
			IComplexTest compTest = objRef as IComplexTest;

			return compTest;
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect Interacx
United States United States
Blog: https://marcclifton.wordpress.com/
Home Page: http://www.marcclifton.com
Research: http://www.higherorderprogramming.com/
GitHub: https://github.com/cliftonm

All my life I have been passionate about architecture / software design, as this is the cornerstone to a maintainable and extensible application. As such, I have enjoyed exploring some crazy ideas and discovering that they are not so crazy after all. I also love writing about my ideas and seeing the community response. As a consultant, I've enjoyed working in a wide range of industries such as aerospace, boatyard management, remote sensing, emergency services / data management, and casino operations. I've done a variety of pro-bono work non-profit organizations related to nature conservancy, drug recovery and women's health.

Comments and Discussions