using NUnit.Framework;
using Rhino.Mocks;
using System.Collections.Generic;
using System.Linq;
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 = MockRepository.GenerateMock();
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 { "TINK", "FutureType" });
var l_oSource = new List { "TINK", "Konrad", "FutureType" };
var l_oResult = l_oAccount.DoFilter(l_oSource);
Assert.AreEqual(3, l_oResult.ToList().Count);
Assert.AreEqual("TINK", l_oResult.ToList()[0]);
Assert.AreEqual("Konrad", l_oResult.ToList()[1]);
Assert.AreEqual("FutureType", l_oResult.ToList()[2]);
}
///
[Test]
public void TestDoFilter()
{
var l_oAccount = MockRepository.GenerateMock();
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 { "TINK", "FutureType" });
var l_oSource = new List { "TINK", "Konrad", "FutureType" };
var l_oResult = l_oAccount.DoFilter(l_oSource);
Assert.AreEqual(2, l_oResult.ToList().Count);
Assert.AreEqual("TINK", l_oResult.ToList()[0]);
Assert.AreEqual("FutureType", l_oResult.ToList()[1]);
}
}
}