예제 #1
0
        public async Task DeleteTest_Users_ReturnNull()
        {
            var options = new DbContextOptionsBuilder <AppDbContext>()
                          .UseInMemoryDatabase(databaseName: "UserDatabase")
                          .Options;

            using (var context = new AppDbContext(options))
            {
                context.ct_user.Add(new User {
                    Id = 1, Email = "*****@*****.**", Name = "jeremey", Password = "******"
                });
                context.SaveChanges();
            }

            using (var context = new AppDbContext(options))
            {
                UserRepos userrepos = new UserRepos(context);
                await userrepos.Delete(1);

                User getuser;
                getuser = await userrepos.GetAsync(1);

                Assert.IsNull(getuser);
            }
        }
예제 #2
0
        public async Task AddTestUsers_AreNotEqual()
        {
            var options = new DbContextOptionsBuilder <AppDbContext>()
                          .UseInMemoryDatabase(databaseName: "UserDatabase")
                          .Options;

            using (var context = new AppDbContext(options))
            {
                context.ct_user.Add(new User {
                    Id = 1, Email = "*****@*****.**", Name = "jeremey", Password = "******"
                });
                context.SaveChanges();
            }

            using (var context = new AppDbContext(options))
            {
                UserRepos userrepos = new UserRepos(context);
                User      user      = new User();
                User      getuser;
                user.Id       = 2;
                user.Email    = "*****@*****.**";
                user.Name     = "jeremey2";
                user.Password = "******";
                await userrepos.Add(user);

                getuser = await userrepos.GetAsync(1);

                Assert.AreNotEqual(user, getuser);
            }
        }