diff --git a/source/Zyan.Tests/RecreateComponentHostTests.cs b/source/Zyan.Tests/RecreateComponentHostTests.cs index dd703f93..4861a933 100644 --- a/source/Zyan.Tests/RecreateComponentHostTests.cs +++ b/source/Zyan.Tests/RecreateComponentHostTests.cs @@ -4,11 +4,13 @@ using System.Text; using System.IO; using System.Reflection; +using System.Runtime.Remoting.Messaging; using Zyan.Communication; -using Zyan.Communication.Security; using Zyan.Communication.Protocols; using Zyan.Communication.Protocols.Null; using Zyan.Communication.Protocols.Tcp; +using Zyan.Communication.Security; +using Zyan.Communication.SessionMgmt; namespace Zyan.Tests { diff --git a/source/Zyan.Tests/SessionVariableTests.cs b/source/Zyan.Tests/SessionVariableTests.cs new file mode 100644 index 00000000..07e2804f --- /dev/null +++ b/source/Zyan.Tests/SessionVariableTests.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; +using System.Reflection; +using System.Runtime.Remoting.Messaging; +using Zyan.Communication; +using Zyan.Communication.Protocols; +using Zyan.Communication.Protocols.Null; +using Zyan.Communication.Protocols.Tcp; +using Zyan.Communication.Security; +using Zyan.Communication.SessionMgmt; + +namespace Zyan.Tests +{ + #region Unit testing platform abstraction layer +#if NUNIT + using NUnit.Framework; + using TestClass = NUnit.Framework.TestFixtureAttribute; + using TestMethod = NUnit.Framework.TestAttribute; + using ClassInitializeNonStatic = NUnit.Framework.TestFixtureSetUpAttribute; + using ClassInitialize = DummyAttribute; + using ClassCleanupNonStatic = NUnit.Framework.TestFixtureTearDownAttribute; + using ClassCleanup = DummyAttribute; + using TestContext = System.Object; +#else + using Microsoft.VisualStudio.TestTools.UnitTesting; + using ClassInitializeNonStatic = DummyAttribute; + using ClassCleanupNonStatic = DummyAttribute; +#endif + #endregion + + /// + /// Test class for session variables + /// + [TestClass] + public class SessionVariableTests + { + public interface ISessionSample + { + string Get(string name); + void Set(string name, string value); + } + + public class SessionSample : ISessionSample + { + static ISessionVariableAdapter V => ServerSession.CurrentSession.SessionVariables; + public string Get(string name) => V.GetSessionVariable(name, "failed"); + public void Set(string name, string value) => V[name] = value; + } + + [TestMethod] + public void SessionVariablesAreStoredWithinTheCurrentSession() + { + var server = new NullServerProtocolSetup(123); + var client = new NullClientProtocolSetup(); + + using (var host = new ZyanComponentHost("SessionSample", server)) + { + host.RegisterComponent(); + + using (var conn = new ZyanConnection(client.FormatUrl(123, "SessionSample"), client)) + { + var proxy = conn.CreateProxy(); + proxy.Set("Hello", "World"); + Assert.AreEqual("World", proxy.Get("Hello")); + } + } + } + } +} diff --git a/source/Zyan.Tests/Zyan.Tests.Fx3.csproj b/source/Zyan.Tests/Zyan.Tests.Fx3.csproj index 3396654f..2191d83e 100644 --- a/source/Zyan.Tests/Zyan.Tests.Fx3.csproj +++ b/source/Zyan.Tests/Zyan.Tests.Fx3.csproj @@ -107,6 +107,7 @@ + diff --git a/source/Zyan.Tests/Zyan.Tests.Mono.csproj b/source/Zyan.Tests/Zyan.Tests.Mono.csproj index a641d6c1..7321fbdc 100644 --- a/source/Zyan.Tests/Zyan.Tests.Mono.csproj +++ b/source/Zyan.Tests/Zyan.Tests.Mono.csproj @@ -88,6 +88,7 @@ + diff --git a/source/Zyan.Tests/Zyan.Tests.NUnit.csproj b/source/Zyan.Tests/Zyan.Tests.NUnit.csproj index 4be9a685..695902ba 100644 --- a/source/Zyan.Tests/Zyan.Tests.NUnit.csproj +++ b/source/Zyan.Tests/Zyan.Tests.NUnit.csproj @@ -101,6 +101,7 @@ + diff --git a/source/Zyan.Tests/Zyan.Tests.csproj b/source/Zyan.Tests/Zyan.Tests.csproj index b7e1e1c6..6a2621dd 100644 --- a/source/Zyan.Tests/Zyan.Tests.csproj +++ b/source/Zyan.Tests/Zyan.Tests.csproj @@ -116,6 +116,7 @@ +