Version 3.0.361

This commit is contained in:
Anja 2023-03-08 13:18:54 +01:00
parent faf68061f4
commit cba4da9357
88 changed files with 1119 additions and 1502 deletions

View file

@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
namespace UITest.Fixtures.ObjectTests.User.Account
{
[TestFixture]
public class TestAccount
{
[Test]
public void TestConstruct()
{
// Act
var account = new TINK.Model.User.Account.Account(
"hans.musterman@hotmail.com", // Mail
"myPasswd", // Pwd
false,
"aktuellerKeks", // Cookie
new List<string> { "Honkey", "Tonkey" }, // Group
TINK.Model.User.Account.Permissions.None);
// Assert
Assert.AreEqual("hans.musterman@hotmail.com", account.Mail);
Assert.AreEqual("myPasswd", account.Pwd);
Assert.That(account.IsAgbAcknowledged, Is.False);
Assert.AreEqual("aktuellerKeks", account.SessionCookie);
Assert.AreEqual("Honkey,Tonkey", String.Join(",", account.Group));
Assert.AreEqual(TINK.Model.User.Account.Permissions.None, account.DebugLevel);
}
[Test]
public void TestConstruct_Copy()
{
var account = new TINK.Model.User.Account.Account(new TINK.Model.User.Account.Account(
"a@b",
"112",
true, // Agbs have been acknowledged
"3330",
new List<string> { "Honkey", "Tonkey" },
TINK.Model.User.Account.Permissions.None));
Assert.AreEqual("a@b", account.Mail);
Assert.AreEqual("112", account.Pwd);
Assert.That(account.IsAgbAcknowledged, Is.True);
Assert.AreEqual("3330", account.SessionCookie);
Assert.AreEqual("Honkey,Tonkey", String.Join(",", account.Group));
Assert.AreEqual(TINK.Model.User.Account.Permissions.None, account.DebugLevel);
}
[Test]
public void TestConstruct_InvalidGroup()
{
Assert.Throws<ArgumentException>(() => new TINK.Model.User.Account.Account("a@b", "112", false, "3330", null, TINK.Model.User.Account.Permissions.None));
Assert.Throws<ArgumentException>(() => new TINK.Model.User.Account.Account(null));
}
}
}

View file

@ -0,0 +1,30 @@
using NUnit.Framework;
using TINK.Model.User.Account;
namespace TestTINKLib
{
[TestFixture]
public class TestValidator
{
[Test]
public void TestValidateMailAndPasswordDelegate()
{
Assert.AreEqual(Elements.None, Validator.ValidateMailAndPasswordDelegate(null, null).ValidElement);
Assert.AreEqual(Elements.None, Validator.ValidateMailAndPasswordDelegate("", null).ValidElement);
Assert.AreEqual(Elements.None, Validator.ValidateMailAndPasswordDelegate("a", null).ValidElement);
Assert.AreEqual(Elements.None, Validator.ValidateMailAndPasswordDelegate("a@", null).ValidElement);
Assert.AreEqual(Elements.Mail, Validator.ValidateMailAndPasswordDelegate("a@c", "").ValidElement);
Assert.AreEqual(Elements.Mail, Validator.ValidateMailAndPasswordDelegate("a@c", "123").ValidElement);
Assert.AreEqual(Elements.Mail | Elements.Password, Validator.ValidateMailAndPasswordDelegate("a@c", "123456789" /* password */).ValidElement);
}
}
}

View file

@ -0,0 +1,99 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using NUnit.Framework;
using TestFramework.Model.User.Account;
using TINK.Model.Connector;
using TINK.Model.User;
using TINK.Model.User.Account;
using TINK.Repository;
using static TINK.Repository.CopriCallsMemory;
namespace TestTINKLib
{
[TestFixture]
public class TestUser
{
[Test]
public void TestConstruct_NotLoggedIn_NoUsername()
{
var storeMock = new StoreMock(); // Account without user name, password and cookie
var l_oUser = new User(
storeMock,
storeMock.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 storeMock = new StoreMock(new Account("John", "123", true, null, new List<string>())); // Account without session cookie.
var user = new User(
storeMock,
storeMock.Load().Result,
"123456789");
Assert.IsFalse(user.IsLoggedIn);
Assert.AreEqual("John", user.Mail);
Assert.AreEqual("123", user.Password);
Assert.IsNull(user.SessionCookie);
}
[Test]
public void TestConstruct_LoggedIn()
{
var l_oStoreMock = new StoreMock(new Account("John", "123", false, "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 async Task TestSetCredentials()
{
var l_oConnector = new ConnectorCache(
new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)),
null /*UI language */,
string.Empty,
string.Empty,
server: new CopriCallsMemory("MyMerchId", 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;
await l_oUser.Login(l_oAccount);
Assert.IsTrue(l_oUser.IsLoggedIn);
Assert.AreEqual(LoginSessionCopriInfo.JavaministerHardwareNr1.Mail, l_oUser.Mail);
}
}
}