using System;
using NSubstitute;
using NUnit.Framework;
using ShareeBike.Model.Connector;
using ShareeBike.Repository;
namespace SharedBusinessLogic.Tests.Fixtures.ObjectTests.Connector
{
[TestFixture]
public class TestConnectorCache
{
///
/// Verifies that factory method returns correcty type depending on session cookie.
///
[Test]
public void TestCommandFactory()
{
var l_oCopri = Substitute.For();
// Construct not logged in version of connector.
var l_oCommand = new ConnectorCache(
new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)),
null /*UI language */,
"", // Not logged in
"",
server: l_oCopri).Command;
Assert.That(l_oCommand.GetType(), Is.EqualTo(typeof(Command)));
}
///
/// Verifies that factory method returns correcty type depending on session cookie.
///
[Test]
public void TestCommandFactory_LoggedIn()
{
var l_oCopri = Substitute.For();
var l_oCommand = new ConnectorCache(
new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)),
null /*UI language */,
"123", // Logged in
"a@b",
server: l_oCopri).Command;
Assert.That(l_oCommand.GetType(), Is.EqualTo(typeof(CommandLoggedIn)));
}
///
/// Verifies that factory method returns correcty type depending on session cookie.
///
[Test]
public void TestQueryFactory_CachedServer()
{
var l_oCopri = Substitute.For();
var l_oQuery = new ConnectorCache(
new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)),
null /*UI language */,
"",
"",
server: l_oCopri).Query;
Assert.That(l_oQuery.GetType(), Is.EqualTo(typeof(ShareeBike.Model.Connector.Query)));
}
///
/// Verifies that factory method returns correcty type depending on session cookie.
///
[Test]
public void TestQueryFactory_LoggedIn()
{
var l_oCopri = Substitute.For();
var l_oQuery = new ConnectorCache(
new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)),
null /*UI language */,
"123",
"a@b",
server: l_oCopri).Query;
Assert.That(l_oQuery.GetType(), Is.EqualTo(typeof(QueryLoggedIn)));
}
}
}