public void GetThatMatchesMultipleRecordsThrowsException() { const string duplicatedAuthor = "John"; var guid1 = AddPoopingToDb(duplicatedAuthor, 5, TimeSpan.FromSeconds(1)); var guid2 = AddPoopingToDb(duplicatedAuthor, 16, TimeSpan.FromSeconds(1)); Assert.AreNotEqual(guid2, guid1); Assert.ThrowsException <InvalidOperationException>( () => PoopingRepository.GetSingle(p => p.Author == duplicatedAuthor)); }
public void GetSingleReturnsCorrectEntity() { var guid1 = AddPoopingToDb("John", 5, TimeSpan.FromSeconds(1)); var guid2 = AddPoopingToDb("Jane", 16, TimeSpan.FromSeconds(2)); var guid3 = AddPoopingToDb("Janice", 22, TimeSpan.FromSeconds(3)); AssertEntitiesAreEqual(guid1, "John", 5, TimeSpan.FromSeconds(1), PoopingRepository.GetSingle(e => e.Author == "John")); AssertEntitiesAreEqual(guid2, "Jane", 16, TimeSpan.FromSeconds(2), PoopingRepository.GetSingle(e => e.Author == "Jane")); AssertEntitiesAreEqual(guid3, "Janice", 22, TimeSpan.FromSeconds(3), PoopingRepository.GetSingle(e => e.Author == "Janice")); }
public void AddPersistItemInDatabase() { PoopingRepository.Add(new PoopingEntity { Author = "Czesio", Duration = new TimeSpan(0, 0, 5), WagePerHour = 15, ExternalId = Guid.NewGuid() }); var pooping = PoopingRepository.GetSingle(e => e.Author == "Czesio"); Assert.AreNotEqual(new Guid(), pooping.ExternalId, "Guid is not random!"); Assert.AreEqual(15, pooping.WagePerHour); Assert.AreEqual("Czesio", pooping.Author); Assert.AreEqual(5, pooping.Duration.TotalSeconds); }