public void UsingTheEntityApi() { ActaStorage storage = new ActaMemoryStorage(); ActaLowLevelApi lowLevel = new ActaDb(storage); ActaEntityApi db = new ActaEntityLayer(lowLevel); // create a new entity var person = new Person {Name = "Marcel", DOB = new DateTime(1972, 4, 30)}; var guid = db.AddOrUpdate(person); // verify that the GUID is valid Assert.AreNotEqual(Guid.Empty, guid); // update an entity person.Name = "Marcel Popescu"; db.AddOrUpdate(person); // retrieve the entity as a list of key/value pairs var pairs = db.Retrieve(guid).ToList(); Assert.AreEqual(Global.TYPE_KEY, pairs[0].Name); Assert.AreEqual("Acta.Tests.Helper.Person", pairs[0].Value); Assert.AreEqual("ID", pairs[1].Name); Assert.AreEqual("NAME", pairs[2].Name); Assert.AreEqual("Marcel Popescu", pairs[2].Value); Assert.AreEqual("DOB", pairs[3].Name); Assert.AreEqual(new DateTime(1972, 4, 30), pairs[3].Value); // retrieve the entity as an object var person2 = db.Retrieve<Person>(guid); Assert.AreEqual(person.Name, person2.Name); Assert.AreEqual(person.DOB, person2.DOB); }
public void SetsTheEntityIdToTheGuid() { var person = new Person(); var result = sut.AddOrUpdate(person); Assert.AreEqual(result, person.Id); }
public void ReturnsAGuid() { var person = new Person(); var result = sut.AddOrUpdate(person); Assert.AreNotEqual(Guid.Empty, result); }
public void ReusesTheEntityIdIfSet() { var guid = Guid.NewGuid(); var person = new Person {Id = guid}; var result = sut.AddOrUpdate(person); Assert.AreEqual(guid, result); Assert.AreEqual(guid, person.Id); }