public void CanAutomaticallyAssignAnId() { var user = new User() { Name = "Harry" }; var dbSession = _database.OpenSession(); dbSession.Store(user); var loadedUser = dbSession.Get<User>(user.PieId()); Assert.AreEqual("Harry", loadedUser.Name); }
public void AnObjectSavedTwiceIsFoundOnce() { var user = new User() { Name = "Harry" }; dbSession.Store(user); dbSession.Store(user); dbSession.Commit(); var user2 = indexer.Query<User>(dbSession, u => u.Name == "Harry").Single(); }
public void CanSearch() { var user = new User() { Name = "Harry" }; dbSession.Store(user); dbSession.Commit(); var user2 = this.indexer.Query<User>(dbSession, u => u.Name == "Harry").Single(); Assert.AreEqual("Harry", user2.Name); Assert.AreEqual(user.PieId(), user2.PieId(), "If these are different, user2 has not been loaded from the database (it has just been rebuilt by the lucene search)"); }
public void CanDelete() { var user = new User() { Name = "Harry" }; var dbSession = _database.OpenSession(); dbSession.Store(user); Assert.Null(_database.OpenSession().Get<User>(user.PieId())); dbSession.Commit(); Assert.NotNull(_database.OpenSession().Get<User>(user.PieId())); dbSession.Remove(user); dbSession.Commit(); Assert.Null(_database.OpenSession().Get<User>(user.PieId())); }
public void CantFindDeletedData() { var user = new User() { Name = "Harry" }; dbSession.Store(user); dbSession.Commit(); Assert.True(indexer.Query<User>(dbSession, u => u.Name == "Harry").Any()); dbSession.Remove(user); dbSession.Commit(); var enumerable = indexer.Query<User>(dbSession, u => u.Name == "Harry").ToArray(); Assert.False(enumerable.Any()); }
public void CanSearchOnUpdatedData() { var user = new User() { Name = "Harry" }; dbSession.Store(user); dbSession.Commit(); var user2 = indexer.Query<User>(dbSession, u => u.Name == "Harry").Single(); user2.Name = "Tom"; dbSession.Store(user2); dbSession.Commit(); var enumerable = indexer.Query<User>(dbSession, u => u.Name == "Harry").ToArray(); Assert.Null(enumerable.SingleOrDefault()); var foundUsingNewName = indexer.Query<User>(dbSession, u => u.Name == "Tom").Single(); Assert.AreEqual("Tom", foundUsingNewName.Name); }
public void PreservesReferences() { var user = new User() { Name = "Harry" }; var task = new Task() { Creator = user, Assignee = user }; var dbSession = _database.OpenSession(); dbSession.Store(task, "asdfg"); var loadedTask = dbSession.Get<Task>("asdfg"); Assert.True(loadedTask.Assignee == loadedTask.Creator); }