mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-06 02:56:32 +01:00
51 lines
1.8 KiB
C#
51 lines
1.8 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using NUnit.Framework;
|
|
using Rhino.Mocks;
|
|
using TINK.Model.Connector;
|
|
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
|
|
l_oAccount.Stub((x) => x.Group).Return(new List<string> { $"HOM_{FilterHelper.CARGOBIKE}", "HOM_117025" });
|
|
|
|
var l_oSource = new List<string> { $"HOM_{FilterHelper.CARGOBIKE}", $"HOM_{FilterHelper.CITYBIKE}", "HOM_117025" };
|
|
|
|
var l_oResult = l_oAccount.DoFilter(l_oSource);
|
|
|
|
Assert.AreEqual(3, l_oResult.ToList().Count);
|
|
Assert.AreEqual($"HOM_{FilterHelper.CARGOBIKE}", l_oResult.ToList()[0]);
|
|
Assert.AreEqual($"HOM_{FilterHelper.CITYBIKE}", l_oResult.ToList()[1]);
|
|
Assert.AreEqual("HOM_117025", l_oResult.ToList()[2]);
|
|
}
|
|
/// <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");
|
|
l_oAccount.Stub((x) => x.Group).Return(new List<string> { $"HOM_{FilterHelper.CARGOBIKE}", "HOM_117025" });
|
|
|
|
var l_oSource = new List<string> { $"HOM_{FilterHelper.CARGOBIKE}", $"HOM_{FilterHelper.CITYBIKE}", "HOM_117025" };
|
|
|
|
var l_oResult = l_oAccount.DoFilter(l_oSource);
|
|
|
|
Assert.AreEqual(2, l_oResult.ToList().Count);
|
|
Assert.AreEqual($"HOM_{FilterHelper.CARGOBIKE}", l_oResult.ToList()[0]);
|
|
Assert.AreEqual("HOM_117025", l_oResult.ToList()[1]);
|
|
}
|
|
}
|
|
}
|