2021-07-12 21:31:46 +02:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using Rhino.Mocks;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2021-11-14 23:27:29 +01:00
|
|
|
|
using TINK.Model.Connector;
|
2021-07-12 21:31:46 +02:00
|
|
|
|
using TINK.Model.User.Account;
|
|
|
|
|
|
|
|
|
|
namespace TestTINKLib.Fixtures.ObjectTests.User.Account
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class TestAccountExtensions
|
|
|
|
|
{
|
|
|
|
|
/// <summary> If no user is logged in filter is not applied. </summary>
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDoFilter_NoUserLoggedIn()
|
|
|
|
|
{
|
|
|
|
|
var l_oAccount = MockRepository.GenerateMock<IAccount>();
|
|
|
|
|
|
|
|
|
|
l_oAccount.Stub((x) => x.Mail).Return("a@b");
|
|
|
|
|
l_oAccount.Stub((x) => x.SessionCookie).Return(""); // User is not logged in
|
2021-11-14 23:27:29 +01:00
|
|
|
|
l_oAccount.Stub((x) => x.Group).Return(new List<string> { $"HOM_{FilterHelper.FILTERTINKGENERAL}", "HOM_117025" });
|
2021-07-12 21:31:46 +02:00
|
|
|
|
|
2021-11-14 23:27:29 +01:00
|
|
|
|
var l_oSource = new List<string> { $"HOM_{FilterHelper.FILTERTINKGENERAL}", $"HOM_{FilterHelper.FILTERKONRAD}", "HOM_117025" };
|
2021-07-12 21:31:46 +02:00
|
|
|
|
|
|
|
|
|
var l_oResult = l_oAccount.DoFilter(l_oSource);
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(3, l_oResult.ToList().Count);
|
2021-11-14 23:27:29 +01:00
|
|
|
|
Assert.AreEqual($"HOM_{FilterHelper.FILTERTINKGENERAL}", l_oResult.ToList()[0]);
|
|
|
|
|
Assert.AreEqual($"HOM_{FilterHelper.FILTERKONRAD}", l_oResult.ToList()[1]);
|
|
|
|
|
Assert.AreEqual("HOM_117025", l_oResult.ToList()[2]);
|
2021-07-12 21:31:46 +02:00
|
|
|
|
}
|
|
|
|
|
/// <summary> </summary>
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDoFilter()
|
|
|
|
|
{
|
|
|
|
|
var l_oAccount = MockRepository.GenerateMock<IAccount>();
|
|
|
|
|
|
|
|
|
|
l_oAccount.Stub((x) => x.Mail).Return("a@b");
|
|
|
|
|
l_oAccount.Stub((x) => x.SessionCookie).Return("123");
|
2021-11-14 23:27:29 +01:00
|
|
|
|
l_oAccount.Stub((x) => x.Group).Return(new List<string> { $"HOM_{FilterHelper.FILTERTINKGENERAL}", "HOM_117025" });
|
2021-07-12 21:31:46 +02:00
|
|
|
|
|
2021-11-14 23:27:29 +01:00
|
|
|
|
var l_oSource = new List<string> { $"HOM_{FilterHelper.FILTERTINKGENERAL}", $"HOM_{FilterHelper.FILTERKONRAD}", "HOM_117025" };
|
2021-07-12 21:31:46 +02:00
|
|
|
|
|
|
|
|
|
var l_oResult = l_oAccount.DoFilter(l_oSource);
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(2, l_oResult.ToList().Count);
|
2021-11-14 23:27:29 +01:00
|
|
|
|
Assert.AreEqual($"HOM_{FilterHelper.FILTERTINKGENERAL}", l_oResult.ToList()[0]);
|
|
|
|
|
Assert.AreEqual("HOM_117025", l_oResult.ToList()[1]);
|
2021-07-12 21:31:46 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|