示例#1
0
        private void BanUserButton_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count != 0)
            {
                int UserID;

                DataGridViewRow row = this.dataGridView1.SelectedRows[0];
                UserID = Convert.ToInt32(row.Cells["UserID"].Value);

                DialogResult dialogResult = MessageBox.Show("Are you sure you would like to ban this user?",
                                                            "Temporarily Ban User", MessageBoxButtons.YesNo);

                if (dialogResult == DialogResult.Yes)
                {
                    userMgmt.BanUser(UserID);
                    LoadUsers();
                    logonMenu.Reload();
                }

                else if (dialogResult == DialogResult.No)
                {
                    //Do nothing
                }
            }
        }
        public void BanUser_CallsCRUD_BanUser_PassingTheUserIDProvided_ExactlyOnce_WhenCalled()
        {
            //Arrange
            int TestUserID = 1;

            Mock <ICRUD_Operations> MockCRUD = new Mock <ICRUD_Operations>();

            UserManagementService UserMgmtService = new UserManagementService(MockCRUD.Object);

            //Act
            UserMgmtService.BanUser(TestUserID);

            //Assert
            MockCRUD.Verify(x => x.BanUser(TestUserID), Times.Once);
        }