Пример #1
0
 static void RunSampleA1()
 {
     var teamRockyId = new TeamId(1);
       var teamRocky = new SampleA1.Team(teamRockyId);
       var teamMemberTheHulkId = new TeamMemberId(2);
       var teamMemberTheHulk = new SampleA1.TeamMember(teamRockyId, teamMemberTheHulkId, new DateTime(2010, 1, 1));
       var teamRepository = new SampleA1.TeamRepository(new Dictionary<TeamId, SampleA1.Team> { { teamRockyId, teamRocky } });
       var teamMemberRepository = new SampleA1.TeamMemberRepository(new Dictionary<TeamMemberId, SampleA1.TeamMember> { { teamMemberTheHulkId, teamMemberTheHulk } });
       var service = new SampleA1.TeamApplicationService(teamRepository, teamMemberRepository);
       var request = new AppointChairmanRequest { TeamId = 1, TeamMemberId = 2 };
       try {
     service.When(request);
       }
       catch (InvalidOperationException) {}
       teamRocky.AddMember(teamMemberTheHulkId);
       service.When(request);
 }
Пример #2
0
        static void RunSampleA1()
        {
            var teamRockyId         = new TeamId(1);
            var teamRocky           = new SampleA1.Team(teamRockyId);
            var teamMemberTheHulkId = new TeamMemberId(2);
            var teamMemberTheHulk   = new SampleA1.TeamMember(teamRockyId, teamMemberTheHulkId, new DateTime(2010, 1, 1));
            var teamRepository      = new SampleA1.TeamRepository(new Dictionary <TeamId, SampleA1.Team> {
                { teamRockyId, teamRocky }
            });
            var teamMemberRepository = new SampleA1.TeamMemberRepository(new Dictionary <TeamMemberId, SampleA1.TeamMember> {
                { teamMemberTheHulkId, teamMemberTheHulk }
            });
            var service = new SampleA1.TeamApplicationService(teamRepository, teamMemberRepository);
            var request = new AppointChairmanRequest {
                TeamId = 1, TeamMemberId = 2
            };

            try {
                service.When(request);
            }
            catch (InvalidOperationException) {}
            teamRocky.AddMember(teamMemberTheHulkId);
            service.When(request);
        }
Пример #3
0
 public void AppointAsChairmanOf(Team team)
 {
     Enforce.That(team.HasMember(_teamMemberId), Sorry.NotPartOfTheTeam);
       Enforce.That(IsMemberSinceAtLeastTwoYears(), Sorry.NotMemberSinceAtLeastTwoYears);
       team.SetChairman(_teamMemberId);
 }