Ejemplo n.º 1
0
        public void Delete_UserShouldBeDeleted()
        {
            TaskManagerEntities taskManagerEntities = new TaskManagerEntities();
            var UserId = taskManagerEntities.Users.Max(x => x.User_Id);


            UserAPIController controller = new UserAPIController();

            controller.Delete(UserId);

            var result = controller.GetUserDetails().Where(x => x.UserId == UserId).FirstOrDefault();


            Assert.IsNull(result);
        }
        public UserAPIControllerTest()
        {
            // Use database to test here, we could mock UserManagementContext if we only need to test controller.
            var optionsBuilder = new DbContextOptionsBuilder <UserManagementContext>();

            optionsBuilder.UseSqlServer(@"Server=localhost\SQLExpress;Database=UserManagement;UID=sa;PWD=Abcd1234;");
            UserManagementContext domainContext = new UserManagementContext(optionsBuilder.Options);

            // Auto Mapper Configurations
            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new MappingProfile());
            });

            IMapper mapper = mappingConfig.CreateMapper();

            usersController = new UserAPIController(new UserRepository(domainContext, mapper));
        }
        private void SignInButton_Click(object sender, EventArgs e)
        {
            if (this.LogInEditText.Text == "" || this.PasswordEditText.Text == "")
            {
                this.LogInTitleTextView.Text = "Please enter all the fields.";
                return;
            }

            if (!UserAPIController.SigeIn(this.LogInEditText.Text, this.PasswordEditText.Text))
            {
                this.LogInTitleTextView.Text = "Wrong login or password.";
                return;
            }

            var nextActivity = new Intent(this, typeof(HomeActivity));

            StartActivity(nextActivity);
        }
Ejemplo n.º 4
0
        public void CreateUser_UserShouldBeAdded()
        {
            User User = new User();

            User.First_Name   = "Test User";
            User.Last_Name    = "Test User";
            User.Manager_Flag = true;



            UserAPIController controller = new UserAPIController();

            controller.Create(User);

            var result = controller.GetUserDetails().Where(x => x.FirstName == "Test User").FirstOrDefault();

            Assert.IsNotNull(result);
            Assert.AreEqual(result.FirstName, "Test User");
        }
Ejemplo n.º 5
0
        public void UpdateUser_UserShouldBeUpdated()
        {
            TaskManagerEntities taskManagerEntities = new TaskManagerEntities();
            var  UserId = taskManagerEntities.Users.Max(x => x.User_Id);
            User User   = new User();

            User.User_Id      = UserId;
            User.First_Name   = "Updated Test User";
            User.Last_Name    = "Test User";
            User.Manager_Flag = true;

            UserAPIController controller = new UserAPIController();

            controller.Update(User);

            var result = controller.GetUserDetails().Where(x => x.UserId == UserId).FirstOrDefault();

            Assert.IsNotNull(result);
            Assert.AreEqual(result.FirstName, "Updated Test User");
        }
Ejemplo n.º 6
0
        public void GetUserByID_NonExits()
        {
            #region Assign
            UserRepoTest      testData       = new UserRepoTest();
            UserAPIController testController = new UserAPIController(testData);

            #endregion

            #region  Act

            var taskReturn = testController.GetUser(1);
            taskReturn.Wait();
            var result = taskReturn.Result.Value;
            #endregion

            #region

            Assert.AreEqual(result.Username, "Swag0");

            #endregion
        }
Ejemplo n.º 7
0
        private void SaveUpButton_Click(object sender, EventArgs e)
        {
            if (this.PasswordEditText.Text != this.PasswordEditText2.Text)
            {
                View view = (View)sender;
                Snackbar.Make(view, "Passwords do not match.", Snackbar.LengthLong)
                .SetAction("Action", (Android.Views.View.IOnClickListener)null).Show();
                return;
            }

            var user    = UserAPIController.User;
            var newUser = new UserModel(
                user.Name, this.SurNameEditText.Text,
                null,
                null,
                user.Login,
                this.PasswordEditText.Text,
                null,
                null);

            UserAPIController.UpdateCustomer(newUser);
            StartActivity(typeof(HomeActivity));
        }
Ejemplo n.º 8
0
 // GET: Team
 public TeamController()
 {
     _teamapicontroller = new TeamAPIController();
     _userapicontroller = new UserAPIController();
 }
Ejemplo n.º 9
0
 public UserRightsController()
 {
     _userapicontroller = new UserAPIController();
 }
Ejemplo n.º 10
0
 public UserController()
 {
     _userapicontroller   = new UserAPIController();
     _CommonAPIController = new CommonAPIController();
 }