2023-04-05 15:02:10 +02:00
|
|
|
using System.Collections.Generic;
|
2021-07-12 21:31:46 +02:00
|
|
|
using System.Linq;
|
2023-04-05 15:02:10 +02:00
|
|
|
using NSubstitute;
|
2022-08-30 15:42:25 +02:00
|
|
|
using NUnit.Framework;
|
2024-04-09 12:53:23 +02:00
|
|
|
using ShareeBike.Model.Connector;
|
|
|
|
using ShareeBike.Model.User.Account;
|
2021-07-12 21:31:46 +02:00
|
|
|
|
2024-04-09 12:53:23 +02:00
|
|
|
namespace SharedBusinessLogic.Tests.Fixtures.ObjectTests.User.Account
|
2021-07-12 21:31:46 +02:00
|
|
|
{
|
2022-09-06 16:08:19 +02:00
|
|
|
[TestFixture]
|
|
|
|
public class TestAccountExtensions
|
|
|
|
{
|
|
|
|
/// <summary> If no user is logged in filter is not applied. </summary>
|
|
|
|
[Test]
|
|
|
|
public void TestDoFilter_NoUserLoggedIn()
|
|
|
|
{
|
2023-04-05 15:02:10 +02:00
|
|
|
var l_oAccount = Substitute.For<IAccount>();
|
2022-09-06 16:08:19 +02:00
|
|
|
|
2023-04-05 15:02:10 +02:00
|
|
|
l_oAccount.Mail.Returns("a@b");
|
|
|
|
l_oAccount.SessionCookie.Returns(""); // User is not logged in
|
|
|
|
l_oAccount.Group.Returns(new List<string> { $"HOM_{FilterHelper.CARGOBIKE}", "HOM_117025" });
|
2022-09-06 16:08:19 +02:00
|
|
|
|
|
|
|
var l_oSource = new List<string> { $"HOM_{FilterHelper.CARGOBIKE}", $"HOM_{FilterHelper.CITYBIKE}", "HOM_117025" };
|
|
|
|
|
|
|
|
var l_oResult = l_oAccount.DoFilter(l_oSource);
|
|
|
|
|
2024-04-09 12:53:23 +02:00
|
|
|
Assert.That(l_oResult.ToList().Count, Is.EqualTo(3));
|
|
|
|
Assert.That(l_oResult.ToList()[0], Is.EqualTo($"HOM_{FilterHelper.CARGOBIKE}"));
|
|
|
|
Assert.That(l_oResult.ToList()[1], Is.EqualTo($"HOM_{FilterHelper.CITYBIKE}"));
|
|
|
|
Assert.That(l_oResult.ToList()[2], Is.EqualTo("HOM_117025"));
|
2022-09-06 16:08:19 +02:00
|
|
|
}
|
|
|
|
/// <summary> </summary>
|
|
|
|
[Test]
|
|
|
|
public void TestDoFilter()
|
|
|
|
{
|
2023-04-05 15:02:10 +02:00
|
|
|
var l_oAccount = Substitute.For<IAccount>();
|
2022-09-06 16:08:19 +02:00
|
|
|
|
2023-04-05 15:02:10 +02:00
|
|
|
l_oAccount.Mail.Returns("a@b");
|
|
|
|
l_oAccount.SessionCookie.Returns("123");
|
|
|
|
l_oAccount.Group.Returns(new List<string> { $"HOM_{FilterHelper.CARGOBIKE}", "HOM_117025" });
|
2022-09-06 16:08:19 +02:00
|
|
|
|
|
|
|
var l_oSource = new List<string> { $"HOM_{FilterHelper.CARGOBIKE}", $"HOM_{FilterHelper.CITYBIKE}", "HOM_117025" };
|
|
|
|
|
|
|
|
var l_oResult = l_oAccount.DoFilter(l_oSource);
|
|
|
|
|
2024-04-09 12:53:23 +02:00
|
|
|
Assert.That(l_oResult.ToList().Count, Is.EqualTo(2));
|
|
|
|
Assert.That(l_oResult.ToList()[0], Is.EqualTo($"HOM_{FilterHelper.CARGOBIKE}"));
|
|
|
|
Assert.That(l_oResult.ToList()[1], Is.EqualTo("HOM_117025"));
|
2022-09-06 16:08:19 +02:00
|
|
|
}
|
|
|
|
}
|
2021-07-12 21:31:46 +02:00
|
|
|
}
|