Esempio n. 1
0
        public void GetUserById()
        {
            var user = new User()
            {
                UserId = 4, Username = "******"
            };

            var result1 = new User();
            var result2 = new User();

            using (var context = new InTheKitchenDBContext(testOptions))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();
                context.Add(user);
                context.SaveChanges();
                result2 = context.Users.FirstOrDefault(u => u.UserId == user.UserId);
            }

            using (var context = new InTheKitchenDBContext(testOptions))
            {
                context.Database.EnsureCreated();
                var msr = new KitchenRepository(context);
                result1 = msr.GetUserDataById(user.UserId);
            }

            Assert.Equal(result1.Username, result2.Username);
        }