Skip to content

Commit

Permalink
Added SessionVariableTests to keep the coverage tracker happy.
Browse files Browse the repository at this point in the history
  • Loading branch information
yallie committed Aug 3, 2020
1 parent da29290 commit e8adcf8
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 1 deletion.
4 changes: 3 additions & 1 deletion source/Zyan.Tests/RecreateComponentHostTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
72 changes: 72 additions & 0 deletions source/Zyan.Tests/SessionVariableTests.cs
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"));
}
}
}
}
}
1 change: 1 addition & 0 deletions source/Zyan.Tests/Zyan.Tests.Fx3.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<Compile Include="RecreateComponentHostTests.cs" />
<Compile Include="SafeDynamicInvokerTests.cs" />
<Compile Include="SecureRemotePasswordTests.cs" />
<Compile Include="SessionVariableTests.cs" />
<Compile Include="SrpAuthenticationTests.cs" />
<Compile Include="SubscriptionTrackerTests.cs" />
<Compile Include="ThreadPoolTests.cs" />
Expand Down
1 change: 1 addition & 0 deletions source/Zyan.Tests/Zyan.Tests.Mono.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ProtocolUrlTests.cs" />
<Compile Include="SecureRemotePasswordTests.cs" />
<Compile Include="SessionVariableTests.cs" />
<Compile Include="SrpAuthenticationTests.cs" />
<Compile Include="StreamTests.cs" />
<Compile Include="SubscriptionTrackerTests.cs" />
Expand Down
1 change: 1 addition & 0 deletions source/Zyan.Tests/Zyan.Tests.NUnit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<Compile Include="RecreateComponentHostTests.cs" />
<Compile Include="SafeDynamicInvokerTests.cs" />
<Compile Include="SecureRemotePasswordTests.cs" />
<Compile Include="SessionVariableTests.cs" />
<Compile Include="SrpAuthenticationTests.cs" />
<Compile Include="StreamTests.cs" />
<Compile Include="SubscriptionTrackerTests.cs" />
Expand Down
1 change: 1 addition & 0 deletions source/Zyan.Tests/Zyan.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
<Compile Include="RecreateComponentHostTests.cs" />
<Compile Include="SafeDynamicInvokerTests.cs" />
<Compile Include="SecureRemotePasswordTests.cs" />
<Compile Include="SessionVariableTests.cs" />
<Compile Include="SrpAuthenticationTests.cs" />
<Compile Include="StreamTests.cs" />
<Compile Include="SubscriptionTrackerTests.cs" />
Expand Down

0 comments on commit e8adcf8

Please sign in to comment.