sharee.bike-App/TestShareeLib/Model/Connector/TestConnectorCache.cs
2023-04-05 15:02:10 +02:00

85 lines
2.2 KiB
C#

using System;
using NSubstitute;
using NUnit.Framework;
using TINK.Model.Connector;
using TINK.Repository;
namespace TestTINKLib.Fixtures.ObjectTests.Connector
{
[TestFixture]
public class TestConnectorCache
{
/// <summary>
/// Verifies that factory method returns correcty type depending on session cookie.
/// </summary>
[Test]
public void TestCommandFactory()
{
var l_oCopri = Substitute.For<ICopriServer>();
// 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.AreEqual(typeof(Command), l_oCommand.GetType());
}
/// <summary>
/// Verifies that factory method returns correcty type depending on session cookie.
/// </summary>
[Test]
public void TestCommandFactory_LoggedIn()
{
var l_oCopri = Substitute.For<ICopriServer>();
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.AreEqual(typeof(CommandLoggedIn), l_oCommand.GetType());
}
/// <summary>
/// Verifies that factory method returns correcty type depending on session cookie.
/// </summary>
[Test]
public void TestQueryFactory_CachedServer()
{
var l_oCopri = Substitute.For<ICopriServer>();
var l_oQuery = new ConnectorCache(
new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)),
null /*UI language */,
"",
"",
server: l_oCopri).Query;
Assert.AreEqual(typeof(TINK.Model.Connector.Query), l_oQuery.GetType());
}
/// <summary>
/// Verifies that factory method returns correcty type depending on session cookie.
/// </summary>
[Test]
public void TestQueryFactory_LoggedIn()
{
var l_oCopri = Substitute.For<ICopriServer>();
var l_oQuery = new ConnectorCache(
new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)),
null /*UI language */,
"123",
"a@b",
server: l_oCopri).Query;
Assert.AreEqual(typeof(QueryLoggedIn), l_oQuery.GetType());
}
}
}