|
using System;
using System.Runtime.Serialization;
using Vts.UnitTest;
using Interfaces;
namespace ClientTests
{
[TestFixture]
public class ConnectionTests
{
internal delegate void RemoteAsyncDelegate();
[TestFixtureSetUp]
public void TestFixtureSetup()
{
RemotingHelper.LoadConfiguration("clientConfig.xml");
}
[TestFixtureTearDown]
public void TestFixtureTearDown()
{
RemotingHelper.UnloadConfiguration();
}
[Test]
public void InstancePerCallTest()
{
ITest t1 = RemotingHelper.CreatePerCallTestObject();
t1.Value1 = 1;
t1.Value2 = 2;
Assertion.Assert(t1.Value1 == 0, "Expected t1.Value1 to be 0 for a single call activation remote object.");
}
[Test]
public void SingletonActivationTest()
{
ITest t1 = RemotingHelper.CreateSingletonTestObject();
t1.Value1 = 1;
t1.Value2 = 2;
Assertion.Assert(t1.Value1 == 1, "Expected t1.Value1 to be 1 for a singleton remote object.");
ITest t2 = RemotingHelper.CreateSingletonTestObject();
Assertion.Assert(t2.Value1 == 1, "Expected t2.Value1 to be 1 for a second instance of the singleton object.");
}
[Test]
public void SameReferenceTest()
{
ITest t1 = RemotingHelper.CreateSingletonTestObject();
ITest t2 = RemotingHelper.CreateSingletonTestObject();
Assertion.Assert(t1 == t2, "Expected t1==t2.");
}
[Test]
public void FactoryActivationTest()
{
IFactory factory = RemotingHelper.CreateFactoryObject();
ITest t1 = factory.CreateTest();
t1.Value1 = 1;
t1.Value2 = 2;
Assertion.Assert(t1.Value1 == 1, "Expected t1.Value1 to be 1 for a factory created remote object.");
ITest t2 = factory.CreateTest();
Assertion.Assert(t2.Value1 == 0, "Expected t2.Value1 to be 0 for a second instance of a factory created remote object.");
}
[Test]
public void FactoryDifferentReferenceTest()
{
IFactory factory = RemotingHelper.CreateFactoryObject();
ITest t1 = factory.CreateTest();
ITest t2 = factory.CreateTest();
Assertion.Assert(t1 != t2, "Expected t1 != t2.");
}
[Test]
[ExpectedException(typeof(Exception))]
public void SystemExceptionTest()
{
ITest t1 = RemotingHelper.CreateSingletonTestObject();
t1.CreateSystemException();
}
[Test]
[ExpectedException(typeof(SerializationException))]
public void CustomExceptionTest()
{
ITest t1 = RemotingHelper.CreateSingletonTestObject();
t1.CreateCustomException();
}
[Test]
[Ignore]
public void InfiniteLoopTest()
{
ITest t1 = RemotingHelper.CreateSingletonTestObject();
t1.InfiniteLoop();
}
[Test]
public void AsyncReturnImmediateTest()
{
ITest t1 = RemotingHelper.CreateSingletonTestObject();
RemoteAsyncDelegate remoteDlgt = new RemoteAsyncDelegate(t1.ReturnImmediately);
remoteDlgt.BeginInvoke(null, null);
}
}
}
|
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.
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