mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-12-23 15:46:29 +01:00
98 lines
3.1 KiB
C#
98 lines
3.1 KiB
C#
|
using NUnit.Framework;
|
|||
|
using TINK.Model.User;
|
|||
|
using TINK.Model.Connector;
|
|||
|
using TestTINKLib.Model.User.Account;
|
|||
|
|
|||
|
using TINK.Model.User.Account;
|
|||
|
using System.Collections.Generic;
|
|||
|
using TINK.Repository;
|
|||
|
|
|||
|
using static TINK.Repository.CopriCallsMemory;
|
|||
|
|
|||
|
namespace TestTINKLib
|
|||
|
{
|
|||
|
|
|||
|
[TestFixture]
|
|||
|
public class TestUser
|
|||
|
{
|
|||
|
[Test]
|
|||
|
public void TestConstruct_NotLoggedIn_NoUsername()
|
|||
|
{
|
|||
|
var l_oStoreMock = new StoreMock(); // Account without user name, password and cookie
|
|||
|
|
|||
|
var l_oUser = new User(
|
|||
|
l_oStoreMock,
|
|||
|
l_oStoreMock.Load().Result,
|
|||
|
"HwId1000000000000");
|
|||
|
|
|||
|
Assert.IsFalse(l_oUser.IsLoggedIn);
|
|||
|
Assert.IsNull(l_oUser.Mail);
|
|||
|
Assert.IsNull(l_oUser.Password);
|
|||
|
Assert.IsNull(l_oUser.SessionCookie);
|
|||
|
}
|
|||
|
|
|||
|
[Test]
|
|||
|
public void TestConstruct_NotLoggedIn_NoCookie()
|
|||
|
{
|
|||
|
var l_oStoreMock = new StoreMock(new Account("John", "123", null, new List<string>())); // Account without session cookie.
|
|||
|
|
|||
|
var l_oUser = new User(
|
|||
|
l_oStoreMock,
|
|||
|
l_oStoreMock.Load().Result,
|
|||
|
"123456789");
|
|||
|
|
|||
|
Assert.IsFalse(l_oUser.IsLoggedIn);
|
|||
|
Assert.AreEqual("John", l_oUser.Mail);
|
|||
|
Assert.AreEqual("123", l_oUser.Password);
|
|||
|
Assert.IsNull(l_oUser.SessionCookie);
|
|||
|
}
|
|||
|
|
|||
|
[Test]
|
|||
|
public void TestConstruct_LoggedIn()
|
|||
|
{
|
|||
|
var l_oStoreMock = new StoreMock(new Account("John", "123", "9512", new List<string> { "TINK" }));
|
|||
|
|
|||
|
var l_oUser = new User(
|
|||
|
l_oStoreMock,
|
|||
|
l_oStoreMock.Load().Result,
|
|||
|
"123456789");
|
|||
|
|
|||
|
Assert.IsTrue(l_oUser.IsLoggedIn, "If store does not hold cookie user is considered to not be logged in");
|
|||
|
|
|||
|
Assert.AreEqual("John", l_oUser.Mail);
|
|||
|
Assert.AreEqual("123", l_oUser.Password);
|
|||
|
Assert.AreEqual("9512", l_oUser.SessionCookie);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>Test logging in. </summary>
|
|||
|
[Test]
|
|||
|
public void TestSetCredentials()
|
|||
|
{
|
|||
|
var l_oConnector = new ConnectorCache(
|
|||
|
string.Empty,
|
|||
|
string.Empty,
|
|||
|
new CopriCallsMemory(SampleSets.Set2, 1));
|
|||
|
|
|||
|
var l_oStoreMock = new StoreMock(); // Account without user name, password and cookie
|
|||
|
|
|||
|
var l_oUser = new User(
|
|||
|
l_oStoreMock,
|
|||
|
l_oStoreMock.Load().Result,
|
|||
|
"HwId1000000000000");
|
|||
|
|
|||
|
Assert.IsFalse(l_oUser.IsLoggedIn);
|
|||
|
Assert.IsNull(l_oUser.Mail);
|
|||
|
|
|||
|
IAccount l_oAccount = l_oConnector.Command.DoLogin(
|
|||
|
LoginSessionCopriInfo.JavaministerHardwareNr1.Mail,
|
|||
|
LoginSessionCopriInfo.JavaministerHardwareNr1.Pwd,
|
|||
|
l_oUser.DeviceId).Result;
|
|||
|
|
|||
|
l_oUser.Login(l_oAccount);
|
|||
|
Assert.IsTrue(l_oUser.IsLoggedIn);
|
|||
|
|
|||
|
Assert.AreEqual(LoginSessionCopriInfo.JavaministerHardwareNr1.Mail, l_oUser.Mail);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|