public void ExistingEntryWithoutUniqueIdIsNotRemoved() { var repository = Substitute.For <ICalendarRepository>(); var entries = new List <JaevnerEntry>(); entries.Add(new JaevnerEntry { StartDateTime = DateTime.Now.AddDays(-2) }); repository.ListEntries().Returns(entries); var service = new JaevnerService(repository); service.RemoveIrrelevantEntries(entries, 10); repository.DidNotReceive().Remove(Arg.Any <JaevnerEntry>()); }
public void ExistingEntryThatIsNotOlderThanNumberOfDaysToKeepIsKept() { const string uniqueId = "123456"; var repository = Substitute.For <ICalendarRepository>(); var entries = new List <JaevnerEntry>(); entries.Add(new JaevnerEntry { UniqueId = uniqueId, StartDateTime = DateTime.Now.AddDays(-2) }); repository.ListEntries().Returns(entries); var service = new JaevnerService(repository); service.RemoveIrrelevantEntries(entries, 10); repository.DidNotReceive().Remove(Arg.Is <JaevnerEntry>(e => e.UniqueId.Equals(uniqueId))); }
public void ExistingEntryInCalendarThatIsNotIncludedInNewDataIsDeleted() { const string uniqueId = "123456"; var repository = Substitute.For <ICalendarRepository>(); repository.ListEntries().Returns(new List <JaevnerEntry> { new JaevnerEntry { UniqueId = uniqueId } }); var service = new JaevnerService(repository); service.RemoveIrrelevantEntries(new List <JaevnerEntry>(), 5); repository.Received().Remove(Arg.Is <JaevnerEntry>(e => e.UniqueId.Equals(uniqueId))); }