public void UsingCompositeKey_UpdatesEntity() { var multiKeyRepository = Container.Resolve <IRepository <Multikey> >(); var m = new Multikey { Key2 = "key", Value = "foo" }; var key = multiKeyRepository.Insert(m); Assert.AreEqual("key", key.Key2); int key1 = key.Key1; string key2 = key.Key2; Multikey m2 = multiKeyRepository .Query(e => e.Key1 == key1 && e.Key2 == key2) .Single(); m2.Key2 = "key"; m2.Value = "barz"; multiKeyRepository.Update(m2); Multikey m3 = multiKeyRepository .Query(e => e.Key1 == key1 && e.Key2 == key2) .Single(); Assert.AreEqual(key1, m3.Key1); Assert.AreEqual("key", m3.Key2); Assert.AreEqual("barz", m3.Value); }
public void AddsEntityToDatabase_ReturnsCompositeKey() { Multikey m = new Multikey { Key2 = "key", Value = "foo" }; var key = Db.Insert(m); Assert.AreEqual(1, key.Key1); Assert.AreEqual("key", key.Key2); }
public void AddsEntityToDatabase_ReturnsCompositeKey() { Multikey m = new Multikey { Key2 = "key", Value = "foo" }; var key = Impl.Insert(Connection, m, null, null); Assert.AreEqual(1, key.Key1); Assert.AreEqual("key", key.Key2); }
public void UsingCompositeKey_DeletesFromDatabase() { Multikey m1 = new Multikey { Key2 = "key", Value = "bar" }; var key = Db.Insert(m1); Multikey m2 = Db.Get <Multikey>(new { key.Key1, key.Key2 }); Db.Delete(m2); Assert.IsNull(Db.Get <Multikey>(new { key.Key1, key.Key2 })); }
public void AddsEntityTo_database_ReturnsCompositeKey() { var multiKeyRepository = _serviceProvider.GetRequiredService <IRepository <Multikey> >(); var m = new Multikey { Key2 = "key", Value = "foo" }; var key = multiKeyRepository.Insert(m); Assert.Equal(1, key.Key1); Assert.Equal("key", key.Key2); }
public void UsingCompositeKey_DeletesFromDatabase() { Multikey m1 = new Multikey { Key2 = "key", Value = "bar" }; var key = Impl.Insert(Connection, m1, null, null); Multikey m2 = Impl.Get <Multikey>(Connection, new { key.Key1, key.Key2 }, null, null); Impl.Delete(Connection, m2, null, null); Assert.IsNull(Impl.Get <Multikey>(Connection, new { key.Key1, key.Key2 }, null, null)); }
public void AddsEntityTo_database_ReturnsCompositeKey() { var multiKeyRepository = Container.Resolve <IRepository <Multikey> >(); var m = new Multikey { Key2 = "key", Value = "foo" }; var key = multiKeyRepository.Insert(m); Assert.AreEqual(1, key.Key1); Assert.AreEqual("key", key.Key2); }
public void UsingCompositeKey_ReturnsEntity() { Multikey m1 = new Multikey { Key2 = "key", Value = "bar" }; var key = Db.Insert(m1); Multikey m2 = Db.Get <Multikey>(new { key.Key1, key.Key2 }); Assert.AreEqual(1, m2.Key1); Assert.AreEqual("key", m2.Key2); Assert.AreEqual("bar", m2.Value); }
public void UsingCompositeKey_ReturnsEntity() { Multikey m1 = new Multikey { Key2 = "key", Value = "bar" }; var key = Impl.Insert(Connection, m1, null, null); Multikey m2 = Impl.Get <Multikey>(Connection, new { key.Key1, key.Key2 }, null, null); Assert.AreEqual(1, m2.Key1); Assert.AreEqual("key", m2.Key2); Assert.AreEqual("bar", m2.Value); }
public void UsingCompositeKey_DeletesFromDatabase() { var m1 = new Multikey { Key2 = "key", Value = "bar" }; var key = Db.Insert(m1).Result; var m2 = Db.Get <Multikey>(new { key.Key1, key.Key2 }).Result; Assert.IsTrue(Db.Delete(m2).Result); var aux = Db.Get <Multikey>(new { key.Key1, key.Key2 }); aux.AsyncState.Should().BeNull(); Dispose(); }
public void UsingCompositeKey_UpdatesEntity() { Multikey m1 = new Multikey { Key2 = "key", Value = "bar" }; var key = Db.Insert(m1); Multikey m2 = Db.Get <Multikey>(new { key.Key1, key.Key2 }); m2.Key2 = "key"; m2.Value = "barz"; Db.Update(m2); Multikey m3 = Db.Get <Multikey>(new { Key1 = 1, Key2 = "key" }); Assert.AreEqual(1, m3.Key1); Assert.AreEqual("key", m3.Key2); Assert.AreEqual("barz", m3.Value); }
public void UsingCompositeKey_DeletesFrom_database() { var multiKeyRepository = Container.Resolve <IRepository <Multikey> >(); var m1 = new Multikey { Key2 = "key", Value = "bar" }; dynamic key = multiKeyRepository.Insert(m1); int key1 = key.Key1; string key2 = key.Key2; Multikey m2 = multiKeyRepository .Query(e => e.Key1 == key1 && e.Key2 == key2) .Single(); bool success = multiKeyRepository.Delete(m2); Assert.IsTrue(success); }
public void UsingCompositeKey_UpdatesEntity() { Multikey m1 = new Multikey { Key2 = "key", Value = "bar" }; var key = Impl.Insert(Connection, m1, null, null); Multikey m2 = Impl.Get <Multikey>(Connection, new { key.Key1, key.Key2 }, null, null); m2.Key2 = "key"; m2.Value = "barz"; Impl.Update(Connection, m2, null, null); Multikey m3 = Impl.Get <Multikey>(Connection, new { Key1 = 1, Key2 = "key" }, null, null); Assert.AreEqual(1, m3.Key1); Assert.AreEqual("key", m3.Key2); Assert.AreEqual("barz", m3.Value); }
public void UsingCompositeKey_ReturnsEntity() { var multiKeyRepository = Container.Resolve <IRepository <Multikey> >(); var m1 = new Multikey { Key2 = "key", Value = "bar" }; dynamic key = multiKeyRepository.Insert(m1); int key1 = key.Key1; string key2 = key.Key2; Multikey m2 = multiKeyRepository .Query(e => e.Key1 == key1 && e.Key2 == key2) .Single(); Assert.AreEqual(key.Key1, m2.Key1); Assert.AreEqual("key", m2.Key2); Assert.AreEqual("bar", m2.Value); }
public void TestMethod5() { using (IDbContext db = new DbContext()) { Multikey entity = new Multikey { Key1 = Guid.NewGuid().ToString(), Key2 = Guid.NewGuid().ToString(), Value = Guid.NewGuid().ToString() }; bool flag = db.Insert <Multikey>(entity); Assert.IsTrue(flag); Multikey result = db.Get <Multikey>(new { Key1 = entity.Key1, Key2 = entity.Key2 }); Assert.IsNotNull(result); Assert.AreEqual(entity.Value, result.Value); bool flag2 = db.Delete <Multikey>(new { Key1 = entity.Key1, Key2 = entity.Key2 }); Assert.IsTrue(flag2); result = db.Get <Multikey>(new { Key1 = entity.Key1, Key2 = entity.Key2 }); Assert.IsNull(result); } }