public void Load_ExistingDocument_ReturnsDocument() { var id = "person-1"; var doc = new Document() {Id = id, Content = "DeserializeMe"}; var bob = DataFactory.GetPerson("Bob", "Twilliger"); var persister = MockRepository.GenerateMock<ICogsPersister>(); var serializer = MockRepository.GenerateMock<IDocumentSerializer>(); var session = new CogsSession(persister, serializer); persister.Expect(p => p.Get(id)).Return(doc); serializer.Expect(s => s.Deserialize<Person>(doc.Content)).Return(bob); var result = session.Load<Person>(id); Assert.AreEqual(bob, result); }
private void Update(Document document) { var db = new Database(Connection); using (var cmd = db.GetSqlStringCommand(PUT_UPDATE_SQL)) { db.AddInParameter(cmd, "id", DbType.String, document.Id); db.AddInParameter(cmd, "doc", DbType.String, document.Content); db.AddInParameter(cmd, "meta", DbType.String, document.Metadata); db.AddInParameter(cmd, "modify", DbType.DateTime, document.ModifyDate); db.ExecuteNonQuery(cmd); } }
public void Put(Document document) { if (document.IsNew) Create(document); else Update(document); }