예제 #1
0
        public async Task DeleteAliasIdentityAsync()
        {
            using (var db = GetSqlDatabase())
            {
                var pOther = new PersonIdentityAlias {
                    First = "OtherAliceAsync", Last = "OtherJones"
                };
                var p = new PersonIdentityAlias {
                    First = "AliceAsync", Last = "Jones"
                };
                Assert.True(await db.InsertAsync(p));
                Assert.True(p.Id > 0);
                Assert.True(await db.InsertAsync(pOther));
                Assert.True(pOther.Id > 0);

                Assert.True(await db.DeleteAsync <PersonIdentityAlias>(p.Id));

                var gp = await db.GetAsync(p);

                var gpOther = await db.GetAsync(pOther);

                Assert.Null(gp);
                Assert.NotNull(gpOther);
            }
        }
        public async Task UpdateComputedAliasAsync()
        {
            var dnow = DateTime.UtcNow;

            using (var db = GetSqlDatabase())
            {
                var p = new PersonIdentityAlias {
                    First = "Alice", Last = "Jones"
                };
                Assert.True(await db.InsertAsync(p));

                if (p.Name != null)
                {
                    Assert.Equal("Alice Jones", p.Name);
                }

                p.First = "Greg";
                p.Last  = "Smith";

                Assert.True(await db.UpdateAsync(p));
                if (p.Name != null)
                {
                    Assert.Equal("Greg Smith", p.Name);
                }

                var gp = await db.GetAsync <PersonIdentityAlias>(p.Id);

                Assert.Equal(p.Id, gp.Id);
                Assert.Equal(p.First, gp.First);
                Assert.Equal(p.Last, gp.Last);
                Assert.Equal(p.Name, gp.Name);

                Assert.True(await db.DeleteAsync <PersonIdentityAlias>(p.Id));

                var dp = await db.GetAsync(p);

                Assert.Null(dp);
            }
        }
예제 #3
0
        public void DeleteAliasIdentity()
        {
            using (var db = GetSqlDatabase())
            {
                var pOther = new PersonIdentityAlias {
                    First = "OtherAlice", Last = "OtherJones"
                };
                var p = new PersonIdentityAlias {
                    First = "Alice", Last = "Jones"
                };
                Assert.True(db.Insert(p));
                Assert.True(p.Id > 0);
                Assert.True(db.Insert(pOther));
                Assert.True(pOther.Id > 0);

                Assert.True(db.Delete <PersonIdentityAlias>(p.Id));

                var gp      = db.Get(p);
                var gpOther = db.Get(pOther);
                Assert.Null(gp);
                Assert.NotNull(gpOther);
            }
        }