Ejemplo n.º 1
0
        public void Delete()
        {
            var userId = Guid.NewGuid();
            var raceId = Guid.NewGuid();
            var teamId = Guid.NewGuid();

            var teamMock = new Team
            {
                TeamId = teamId,
                RaceId = raceId,
            };

            var teamRepositoryMock = new Mock <IGenericRepository <Team> >();

            teamRepositoryMock.Setup(r => r.GetByID(It.Is <Guid>(x => x.Equals(teamId)))).Returns(teamMock);

            _UnitOfWorkMock.Setup(u => u.TeamRepository).Returns(teamRepositoryMock.Object);

            TestUtils.SetupUnitOfWorkToPassAuthorizedAndRace(_UnitOfWorkMock, new List <UserLink> {
                new UserLink()
            }, raceId);

            _Sut.Delete(userId, teamId);

            teamRepositoryMock.Verify(r => r.Delete(It.Is <Guid>(g => g.Equals(teamId))), Times.Once);
            _UnitOfWorkMock.Verify(u => u.Save(), Times.Once);
        }
Ejemplo n.º 2
0
        private void btnRemoveTeam_Click(object sender, EventArgs e)
        {
            DialogResult dr = MetroFramework.MetroMessageBox.Show(this, "Are you Sure?", "Confirmation", MessageBoxButtons.YesNo);

            if (dr == DialogResult.No)
            {
                return;
            }

            if (!ValidationHelper.IsIntValid(txtTID.Text))
            {
                MessageBox.Show("Please select a row first");
                return;
            }

            var result = teamBL.Delete(Int32.Parse(txtTID.Text));

            if (result.HasError)
            {
                MessageBox.Show("Cannot remove " + result.Messages[0]);
                return;
            }

            var tm = teams.FirstOrDefault(t => t.TeamID == result.Data.TeamID);

            if (tm != null)
            {
                teams.Remove(tm);
            }

            this.RefreshDataGrid();
            this.New();
            MessageBox.Show("Operation Completed");
        }