mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-15 22:56:37 +01:00
51 lines
1.8 KiB
C#
51 lines
1.8 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using NSubstitute;
|
|
using NUnit.Framework;
|
|
using ShareeBike.Model.Connector;
|
|
using ShareeBike.Model.User.Account;
|
|
|
|
namespace SharedBusinessLogic.Tests.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 = Substitute.For<IAccount>();
|
|
|
|
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" });
|
|
|
|
var l_oSource = new List<string> { $"HOM_{FilterHelper.CARGOBIKE}", $"HOM_{FilterHelper.CITYBIKE}", "HOM_117025" };
|
|
|
|
var l_oResult = l_oAccount.DoFilter(l_oSource);
|
|
|
|
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"));
|
|
}
|
|
/// <summary> </summary>
|
|
[Test]
|
|
public void TestDoFilter()
|
|
{
|
|
var l_oAccount = Substitute.For<IAccount>();
|
|
|
|
l_oAccount.Mail.Returns("a@b");
|
|
l_oAccount.SessionCookie.Returns("123");
|
|
l_oAccount.Group.Returns(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.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"));
|
|
}
|
|
}
|
|
}
|