Exemple #1
0
        public void Get_All_Users_Equal_To_GetAll()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "Get_All_Users").Options;

            using (var ctx = new ApplicationDbContext(options))
            {
                ctx.ApplicationUsers.Add(new ApplicationUser
                {
                    Id       = "228",
                    UserName = "******"
                });

                ctx.ApplicationUsers.Add(new ApplicationUser
                {
                    Id       = "3332",
                    UserName = "******"
                });

                ctx.SaveChanges();
            }

            //Act
            using (var ctx = new ApplicationDbContext(options))
            {
                var appUserService = new ApplicationUserService(ctx);
                var users          = appUserService.GetAll();

                //Assert
                Assert.AreEqual(users.Count(), 2);
            }
        }