using System.Collections.Generic;
using System.Linq;
using NSubstitute;
using NUnit.Framework;
using TINK.Model.Connector;
using TINK.Model.User.Account;
namespace TestTINKLib.Fixtures.ObjectTests.User.Account
{
[TestFixture]
public class TestAccountExtensions
{
/// If no user is logged in filter is not applied.
[Test]
public void TestDoFilter_NoUserLoggedIn()
{
var l_oAccount = Substitute.For();
l_oAccount.Mail.Returns("a@b");
l_oAccount.SessionCookie.Returns(""); // User is not logged in
l_oAccount.Group.Returns(new List { $"HOM_{FilterHelper.CARGOBIKE}", "HOM_117025" });
var l_oSource = new List { $"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]);
}
///
[Test]
public void TestDoFilter()
{
var l_oAccount = Substitute.For();
l_oAccount.Mail.Returns("a@b");
l_oAccount.SessionCookie.Returns("123");
l_oAccount.Group.Returns(new List { $"HOM_{FilterHelper.CARGOBIKE}", "HOM_117025" });
var l_oSource = new List { $"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]);
}
}
}