Example #1
0
        public void Edit_TeamPassed_EntityIdIsSet()
        {
            // Arrange
            var team    = CreateTeam();
            var captain = CreatePlayer(SPECIFIED_PLAYER_ID);
            var roster  = new PlayerServiceTestFixture()
                          .TestPlayers()
                          .AddPlayer(captain)
                          .Build();

            MockTeamServiceGetTeam(team);
            _teamServiceMock.Setup(ts => ts.GetTeamCaptain(It.IsAny <Team>())).Returns(captain);
            _teamServiceMock.Setup(ts => ts.GetTeamRoster(It.IsAny <int>())).Returns(roster.ToList());

            var viewModel      = CreateViewModel();
            var expectedDomain = viewModel.ToDomain();
            var comparer       = new TeamComparer();

            _teamServiceMock.Setup(ts => ts.Create(It.Is <Team>(t => comparer.AreEqual(t, expectedDomain))))
            .Callback <Team>(t => t.Id = SPECIFIED_TEAM_ID);

            // Act
            var sut = BuildSUT();

            sut.Edit(viewModel);

            // Assert
            Assert.AreEqual(viewModel.Id, SPECIFIED_TEAM_ID);
        }
Example #2
0
        public void Create_TeamPassed_EntityIdIsSet()
        {
            // Arrange
            var viewModel      = new TeamMvcViewModelBuilder().WithId(0).Build();
            var expectedDomain = viewModel.ToDomain();
            var comparer       = new TeamComparer();

            _teamServiceMock.Setup(ts => ts.Create(It.Is <Team>(t => comparer.AreEqual(t, expectedDomain))))
            .Callback <Team>(t => t.Id = SPECIFIED_TEAM_ID);

            // Act
            var sut = BuildSUT();

            sut.Create(viewModel);

            // Assert
            Assert.AreEqual(viewModel.Id, SPECIFIED_TEAM_ID);
        }