public void GetVersesWrittenEarlierFromDate() { IVerseRepository verseRepository = GetRepositoryWithEnrolledUnitOfWork(); var prepared = PreparePoem<NoviceAuthorityType, HaikuPoem>(); VerseType verseType = new CandidateVerseType(); RegisterDataStoreObject(verseType); int numberOfVersesWrittenBeforeThreshold = Rand.Next(10, 20); int numberOfVersesWrittenAfterThreshold = Rand.Next(10, 20); DateTime date = new DateTime(2011, 10, 10); for (int i = 0; i < numberOfVersesWrittenBeforeThreshold; i++) { Verse verse = new Verse { AuthorProfileId = prepared.Item1.Id, FromIpAddress = "127.0.0.1", LastEdit = DateTime.UtcNow, Location = "Chisinau", OrderNr = 1, PoemId = prepared.Item2.Id, Text = Guid.NewGuid().ToString(), VerseTypeId = verseType.Id, WrittenAt = date - TimeSpan.FromDays(10) }; RegisterDataStoreObject(verse); } for (int i = 0; i < numberOfVersesWrittenAfterThreshold; i++) { Verse verse = new Verse { AuthorProfileId = prepared.Item1.Id, FromIpAddress = "127.0.0.1", LastEdit = DateTime.UtcNow, Location = "Chisinau", OrderNr = 1, PoemId = prepared.Item2.Id, Text = Guid.NewGuid().ToString(), VerseTypeId = verseType.Id, WrittenAt = date + TimeSpan.FromDays(10) }; RegisterDataStoreObject(verse); } var afterThreshold = verseRepository.GetVersesWrittenFrom(date); var allItems = verseRepository.GetVersesFromPoem(prepared.Item2.Id); Assert.AreEqual(numberOfVersesWrittenAfterThreshold, afterThreshold.Count()); Assert.AreEqual( numberOfVersesWrittenAfterThreshold + numberOfVersesWrittenBeforeThreshold, allItems.Count()); }
public void SuccessfulCreationAndInsertionOfVerses() { IVerseRepository verseRepository = GetRepositoryWithEnrolledUnitOfWork(); var preparedTupple = PreparePoem<LegendAuthorityType, ClassicalPoem>(); VerseType verseType = new CandidateVerseType(); RegisterDataStoreObject(verseType); Verse verse = new Verse { AuthorProfileId = preparedTupple.Item1.Id, FromIpAddress = "127.0.0.1", LastEdit = DateTime.UtcNow, Location = "Chisinau", OrderNr = 1, PoemId = preparedTupple.Item2.Id, Text = Guid.NewGuid().ToString(), VerseTypeId = verseType.Id, WrittenAt = DateTime.UtcNow }; RegisterDataStoreObject(verse); var actualVerse = verseRepository.GetById(verse.Id); AssertVersesAreEqual(verse, actualVerse); }