Exemplo n.º 1
0
        public void TestGetUserMock()
        {
            IUsersRepository userRepository = new UsersRepositoryMock();
            UserService      userService    = new UserService(userRepository);
            User             user           = userService.GetUserById("194599671");

            Assert.AreEqual("Игорь", user.FirstName);
            Assert.AreEqual("Малахов", user.LastName);
        }
Exemplo n.º 2
0
        public void GetUserByIdMock()
        {
            IUsersRepository userRepository = new UsersRepositoryMock();
            UserService      userService    = new UserService(userRepository);
            User             user           = userService.GetUserById("154951306");

            Assert.AreEqual("Аня", user.FirstName);
            Assert.AreEqual("Зановская", user.LastName);
        }
Exemplo n.º 3
0
        public void GetUserByIdShouldReturnTheCorrectUser()
        {
            var options = new DbContextOptionsBuilder <AppDbContext>()
                          .UseInMemoryDatabase(databaseName: nameof(GetUserByIdShouldReturnTheCorrectUser))
                          .Options;

            using (var context = new AppDbContext(options))
            {
                var userService = new UserService(context, config);

                userService.Register(user);

                var addedUser = context.Users.Last();

                User userById = userService.GetUserById(addedUser.Id);

                Assert.AreEqual(userById.Id, addedUser.Id);
            }
        }