public void IsOverDue_ShouldBeFalseWhenDueDateInPast_ButClosed() { // Arrange _dut = new Action(TestPlant, "TitleA", "DescA", _utcNow); _timeProvider.Elapse(new TimeSpan(1, 0, 0)); _dut.Close(_utcNow, _personMock.Object); // Act var overDue = _dut.IsOverDue(); // Assert Assert.IsFalse(overDue); }
protected override void SetupNewDatabase(DbContextOptions <PreservationContext> dbContextOptions) { using (var context = new PreservationContext(dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { _testDataSet = AddTestDataSet(context); var tag = _testDataSet.Project1.Tags.First(); var attachment = new ActionAttachment(TestPlant, Guid.NewGuid(), "FileA"); _openAction = new Action(TestPlant, "Open", "Desc1", _utcNow); tag.AddAction(_openAction); _closedAction = new Action(TestPlant, "Closed", "Desc2", _utcNow); _closedAction.Close(_utcNow, _testDataSet.CurrentUser); tag.AddAction(_closedAction); var tag2 = _testDataSet.Project1.Tags.Last(); var personMock = new Mock <Person>(); personMock.SetupGet(p => p.Id).Returns(7); _openActionWithEarliestDueTime = new Action(TestPlant, "OpenWithEarliestDueTime", "D2", _dueTimeUtc); _openActionWithDueTime = new Action(TestPlant, "OpenWithDueTime", "D1", _dueTimeUtc); _openActionWithoutDueTime = new Action(TestPlant, "OpenWithoutDueTime", "D3", _dueTimeUtc); _openActionWithoutDueTime.SetDueTime(null); _openAction.AddAttachment(attachment); _closedActionWithEarliestDueTime = new Action(TestPlant, "ClosedWithEarliestDueTime", "D5", _dueTimeUtc); _closedActionWithEarliestDueTime.Close(_utcNow, personMock.Object); _closedActionWithDueTime = new Action(TestPlant, "ClosedWithDueTime", "D4", _dueTimeUtc); _closedActionWithDueTime.Close(_utcNow, personMock.Object); _closedActionWithoutDueTime = new Action(TestPlant, "ClosedWithoutDueTime", "D6", _dueTimeUtc); _closedActionWithoutDueTime.SetDueTime(null); _closedActionWithoutDueTime.Close(_utcNow, personMock.Object); tag2.AddAction(_openActionWithoutDueTime); tag2.AddAction(_closedActionWithoutDueTime); tag2.AddAction(_openActionWithDueTime); tag2.AddAction(_closedActionWithDueTime); tag2.AddAction(_openActionWithEarliestDueTime); tag2.AddAction(_closedActionWithEarliestDueTime); context.SaveChangesAsync().Wait(); _tagId = tag.Id; _tag2Id = tag2.Id; _openActionId = _openAction.Id; _closedActionId = _closedAction.Id; } }
protected override void SetupNewDatabase(DbContextOptions <PreservationContext> dbContextOptions) { using (var context = new PreservationContext(dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { _testDataSet = AddTestDataSet(context); var tag = _testDataSet.Project1.Tags.First(); var attachment = new ActionAttachment(TestPlant, Guid.NewGuid(), "FileA"); _openAction = new Action(TestPlant, "Open", "Desc1", _dueUtc); _openAction.AddAttachment(attachment); tag.AddAction(_openAction); _closedAction = new Action(TestPlant, "Closed", "Desc2", _dueUtc); _closedAction.Close(_utcNow, _testDataSet.CurrentUser); tag.AddAction(_closedAction); context.SaveChangesAsync().Wait(); _tagId = tag.Id; _openActionId = _openAction.Id; _closedActionId = _closedAction.Id; } }
public void SetDueTime_ShouldThrowException_WhenIsClosed() { _dut.Close(_utcNow, _personMock.Object); Assert.ThrowsException <Exception>(() => _dut.SetDueTime(_utcNow)); }