2022-08-30 15:42:25 +02:00
|
|
|
|
using System;
|
|
|
|
|
using NUnit.Framework;
|
2021-07-12 21:31:46 +02:00
|
|
|
|
using Rhino.Mocks;
|
|
|
|
|
using TINK.Model.Connector;
|
|
|
|
|
using TINK.Model.Services.CopriApi;
|
2022-01-04 18:54:03 +01:00
|
|
|
|
using TINK.Repository;
|
2021-07-12 21:31:46 +02:00
|
|
|
|
|
|
|
|
|
namespace TestTINKLib.Fixtures.ObjectTests.Connector
|
|
|
|
|
{
|
2022-09-06 16:08:19 +02:00
|
|
|
|
[TestFixture]
|
|
|
|
|
public class TestConnector
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Verifies that factory method returns correcty type depending on session cookie.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestCommandFactory()
|
|
|
|
|
{
|
|
|
|
|
var l_oCopri = MockRepository.GenerateStub<ICachedCopriServer>();
|
2021-07-12 21:31:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
// Construct not logged in version of connector.
|
|
|
|
|
var l_oCommand = new TINK.Model.Connector.Connector(
|
|
|
|
|
new System.Uri("http://1.2.3.4"),
|
|
|
|
|
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)),
|
|
|
|
|
null /*UI language */,
|
|
|
|
|
"", // Not logged in
|
|
|
|
|
"",
|
|
|
|
|
server: l_oCopri).Command;
|
2021-07-12 21:31:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
Assert.AreEqual(typeof(Command), l_oCommand.GetType());
|
|
|
|
|
}
|
2021-07-12 21:31:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Verifies that factory method returns correcty type depending on session cookie.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestCommandFactory_LoggedIn()
|
|
|
|
|
{
|
|
|
|
|
var l_oCopri = MockRepository.GenerateStub<ICachedCopriServer>();
|
2021-07-12 21:31:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
var l_oCommand = new TINK.Model.Connector.Connector(
|
|
|
|
|
new System.Uri("http://1.2.3.4"),
|
|
|
|
|
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)),
|
|
|
|
|
null /*UI language */,
|
|
|
|
|
"123", // Logged in
|
|
|
|
|
"a@b",
|
|
|
|
|
server: l_oCopri).Command;
|
2021-07-12 21:31:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
Assert.AreEqual(typeof(CommandLoggedIn), l_oCommand.GetType());
|
|
|
|
|
}
|
2021-07-12 21:31:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Verifies that factory method returns correcty type depending on session cookie.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestQueryFactory_CachedServer()
|
|
|
|
|
{
|
|
|
|
|
var l_oCopri = MockRepository.GenerateStub<ICachedCopriServer>();
|
2021-07-12 21:31:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
var l_oQuery = new TINK.Model.Connector.Connector(
|
|
|
|
|
new Uri("http://1.2.3.4"),
|
|
|
|
|
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)),
|
|
|
|
|
null /*UI language */,
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
server: l_oCopri).Query;
|
2021-07-12 21:31:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
Assert.AreEqual(typeof(CachedQuery), l_oQuery.GetType());
|
|
|
|
|
}
|
2021-07-12 21:31:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Verifies that factory method returns correcty type depending on session cookie.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestQueryFactory_LoggedIn()
|
|
|
|
|
{
|
|
|
|
|
var l_oCopri = MockRepository.GenerateStub<ICachedCopriServer>();
|
2021-07-12 21:31:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
var l_oQuery = new TINK.Model.Connector.Connector(
|
|
|
|
|
new System.Uri("http://1.2.3.4"),
|
|
|
|
|
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)),
|
|
|
|
|
null /*UI language */,
|
|
|
|
|
"123",
|
|
|
|
|
"a@b",
|
|
|
|
|
server: l_oCopri).Query;
|
2021-07-12 21:31:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
Assert.AreEqual(typeof(CachedQueryLoggedIn), l_oQuery.GetType());
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-07-12 21:31:46 +02:00
|
|
|
|
}
|