Thanks for the help. I had already tried what you said but I got the
"Method has a non-void return value" test fail message from NUnit.
Here is my code (you probably only need to look at the last part of
this where there is the test method and the static class below that):
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using ACS.Business;
using ACS.Data;
using ACS.BusinessDataBridge;
using ACS.Data.UnitTests;
namespace ACS.BusinessDataBridge.UnitTests.SessionManagerTests
{
[TestFixture]
public class GetNextIdleTooLongTimeTest : DatabaseTestBase
{
private SessionManager _sessionManager;
private TimeSheetsTable _timeSheetsTable;
private ReadsTable _readsTable;
private TimeCardRestraintsTable _timeCardRestraintsTable;
private JobSwitchesTable _jobSwitchesTable;
private BreaksTable _breaksTable;
[SetUp]
public override void SetUp() {
base.SetUp();
_sessionManager = new SessionManager();
_timeSheetsTable = new TimeSheetsTable
(ConnectionSingleton.Instance);
_timeSheetsTable.DeleteAll();
_readsTable = new ReadsTable(new
AlwaysEmptyModifiableReadsRepository());
_readsTable.DeleteAll();
_timeCardRestraintsTable =
new TimeCardRestraintsTable(ConnectionSingleton.Instance);
_timeCardRestraintsTable.DeleteAll();
_jobSwitchesTable = new JobSwitchesTable();
_jobSwitchesTable.DeleteAll();
_breaksTable = new BreaksTable(ConnectionSingleton.Instance);
_breaksTable.DeleteAll();
}
[TearDown]
public override void TearDown() {
_timeSheetsTable.DeleteAll();
_readsTable.DeleteAll();
_readsTable.Dispose();
_timeCardRestraintsTable.DeleteAll();
_jobSwitchesTable.DeleteAll();
_breaksTable.DeleteAll();
base.TearDown();
}
[Test, TestCaseSource(typeof
(GetNextIdleTooLongTimeTestDataProvider),"TestData")]
public DateTime? GetNextIdleTooLongTimeSheet(Session session,
DateTime? expectedNextIdleTooLongTime, DateTime?
expectedLastActivityTime,
ICollection<Read> reads, IEnumerable<TimeCardRestraint> restraints)
{
_readsTable.Insert(reads);
_timeCardRestraintsTable.Insert(restraints);
DateTime? lastActivityTime;
DateTime? nextIdleTooLongTime =
_sessionManager.GetNextIdleTooLongTime(session, out
lastActivityTime);
Assert.That(nextIdleTooLongTime, Is.EqualTo
(expectedNextIdleTooLongTime));
Assert.That(lastActivityTime, Is.EqualTo
(expectedLastActivityTime));
return nextIdleTooLongTime;
}
}
public static class GetNextIdleTooLongTimeTestDataProvider
{
public static IEnumerable TestData {
get {
DateTime? expectedNextIdleTooLongTime = null;
DateTime? expectedLastActivityTime = null;
yield return new TestCaseData(
new Session(),
expectedNextIdleTooLongTime,
expectedLastActivityTime,
new Read[]{},
new TimeCardRestraint[]{})
.SetName("CurrentJobCityIdIsNull")
.Returns(expectedNextIdleTooLongTime);