Пример #1
0
        public void InsertPersonCompositeKey()
        {
            using (var db = GetSqlDatabase())
            {
                var gid = Guid.NewGuid();
                var p   = new PersonCompositeKey {
                    GuidId = gid, StringId = "test", FirstName = "Alice", LastName = "Jones"
                };
                Assert.True(db.Insert(p));
                var gp = db.Get <PersonCompositeKey>($"where GuidId = {P}GuidId and StringId = {P}StringId", p);

                Assert.Equal(p.StringId, gp.StringId);
                Assert.Equal(p.FirstName, gp.FirstName);
                Assert.Equal(p.LastName, gp.LastName);
            }
        }
Пример #2
0
        public async Task DeleteAllAsync()
        {
            using (var db = GetSqlDatabase())
            {
                var pOther = new PersonCompositeKey {
                    GuidId = Guid.NewGuid(), StringId = "testOther", FirstName = "OtherAliceAsync", LastName = "OtherJones"
                };
                var p = new PersonCompositeKey {
                    GuidId = Guid.NewGuid(), StringId = "test", FirstName = "AliceAsync", LastName = "Jones"
                };
                Assert.True(await db.InsertAsync(p));
                Assert.True(await db.InsertAsync(pOther));

                Assert.True(await db.DeleteAllAsync <PersonCompositeKey>());

                Assert.Equal(0, await db.CountAsync <PersonCompositeKey>());
            }
        }
Пример #3
0
        public void DeleteAll()
        {
            using (var db = GetSqlDatabase())
            {
                var pOther = new PersonCompositeKey {
                    GuidId = Guid.NewGuid(), StringId = "testOther", FirstName = "OtherAlice", LastName = "OtherJones"
                };
                var p = new PersonCompositeKey {
                    GuidId = Guid.NewGuid(), StringId = "test", FirstName = "Alice", LastName = "Jones"
                };
                Assert.True(db.Insert(p));
                Assert.True(db.Insert(pOther));

                Assert.True(db.DeleteAll <PersonCompositeKey>());

                Assert.Equal(0, db.Count <PersonCompositeKey>());
            }
        }
        public async Task UpdatePersonCompositeKeyAsync()
        {
            using (var db = GetSqlDatabase())
            {
                var p = new PersonCompositeKey {
                    GuidId = Guid.NewGuid(), StringId = "test", FirstName = "Alice", LastName = "Jones"
                };
                Assert.True(await db.InsertAsync(p));

                p.FirstName = "Greg";
                p.LastName  = "Smith";
                Assert.True(await db.UpdateAsync(p));

                var gp = await db.GetAsync <PersonCompositeKey>($"where GuidId = {P}GuidId and StringId = {P}StringId", p);

                Assert.Equal(p.StringId, gp.StringId);
                Assert.Equal(p.FirstName, gp.FirstName);
                Assert.Equal(p.LastName, gp.LastName);
            }
        }
Пример #5
0
        public void DeletePersonCompositeKey()
        {
            using (var db = GetSqlDatabase())
            {
                var pOther = new PersonCompositeKey {
                    GuidId = Guid.NewGuid(), StringId = "testOther", FirstName = "OtherAlice", LastName = "OtherJones"
                };
                var p = new PersonCompositeKey {
                    GuidId = Guid.NewGuid(), StringId = "test", FirstName = "Alice", LastName = "Jones"
                };
                Assert.True(db.Insert(p));
                Assert.True(db.Insert(pOther));

                Assert.True(db.Delete <PersonCompositeKey>($"where GuidId = {P}GuidId and StringId = {P}StringId", p));

                var gp      = db.Get(p);
                var gpOther = db.Get(pOther);
                Assert.Null(gp);
                Assert.NotNull(gpOther);
            }
        }
Пример #6
0
        public async Task DeletePersonCompositeKeyAsync()
        {
            using (var db = GetSqlDatabase())
            {
                var pOther = new PersonCompositeKey {
                    GuidId = Guid.NewGuid(), StringId = "testOther", FirstName = "OtherAliceAsync", LastName = "OtherJones"
                };
                var p = new PersonCompositeKey {
                    GuidId = Guid.NewGuid(), StringId = "test", FirstName = "AliceAsync", LastName = "Jones"
                };
                Assert.True(await db.InsertAsync(p));
                Assert.True(await db.InsertAsync(pOther));

                Assert.True(await db.DeleteAsync <PersonCompositeKey>($"where GuidId = {P}GuidId and StringId = {P}StringId", p));

                var gp = await db.GetAsync(p);

                var gpOther = await db.GetAsync(pOther);

                Assert.Null(gp);
                Assert.NotNull(gpOther);
            }
        }