-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added SessionVariableTests to keep the coverage tracker happy.
- Loading branch information
Showing
6 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
/// <summary> | ||
/// Test class for session variables | ||
/// </summary> | ||
[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<ISessionSample, SessionSample>(); | ||
|
||
using (var conn = new ZyanConnection(client.FormatUrl(123, "SessionSample"), client)) | ||
{ | ||
var proxy = conn.CreateProxy<ISessionSample>(); | ||
proxy.Set("Hello", "World"); | ||
Assert.AreEqual("World", proxy.Get("Hello")); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters