示例#1
0
        public void Edit()
        {
            var userId = Guid.NewGuid();
            var raceId = Guid.NewGuid();
            var teamId = Guid.NewGuid();

            var teamMock = new Team
            {
                TeamId     = teamId,
                RaceId     = raceId,
                Name       = "Test",
                Number     = 1,
                Category   = TeamCategory.Man,
                FinishTime = DateTime.Now
            };

            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);

            var team = new Team
            {
                TeamId     = teamId,
                RaceId     = raceId,
                Name       = "Blaat",
                Number     = 2,
                Category   = TeamCategory.Woman,
                FinishTime = DateTime.Now
            };

            _Sut.Edit(userId, team);

            teamRepositoryMock.Verify(r => r.Update(It.Is <Team>(x =>
                                                                 x.Name.Equals(team.Name) &&
                                                                 x.Number == team.Number &&
                                                                 x.Category == team.Category &&
                                                                 x.FinishTime.Equals(team.FinishTime)
                                                                 )), Times.Once);
            _UnitOfWorkMock.Verify(u => u.Save(), Times.Once);
        }