コード例 #1
0
 public void GettingSummaryOfEstimatingRoom(Room room, List <ProjectTask> tasks, List <RoomParticipant> participants, List <User> users, ProjectTasksController projectTasksController, GameSummary summary, RoomsController roomsController)
 {
     "Given a list of users"
     .x(() =>
     {
         users = new List <User>()
         {
             new User()
             {
                 id = 1, username = "******", mailAddress = "*****@*****.**"
             },
             new User()
             {
                 id = 2, username = "******", mailAddress = "*****@*****.**"
             },
             new User()
             {
                 id = 3, username = "******", mailAddress = "*****@*****.**"
             },
             new User()
             {
                 id = 4, username = "******", mailAddress = "*****@*****.**"
             },
         };
         _context.User.AddRange(users);
         _context.SaveChanges();
     });
     "And a room"
     .x(() =>
     {
         room = new Room()
         {
             hostMailAddress = users[3].mailAddress, id = 2999, name = "BDD Testing Room"
         };
         _context.Room.Add(room);
         _context.SaveChanges();
     });
     "And list of tasks"
     .x(() =>
     {
         tasks = new List <ProjectTask>()
         {
             new ProjectTask()
             {
                 id = 1, title = "Add a new task", RoomId = 2999, estimate = 0, status = TaskStatus.UNESTIMATED.name, author = users[3]
             },
             new ProjectTask()
             {
                 id = 2, title = "Assign estimates", RoomId = 2999, estimate = 0, status = TaskStatus.UNESTIMATED.name, author = users[3]
             },
             new ProjectTask()
             {
                 id = 3, title = "Sign in to an application", RoomId = 2999, estimate = 0, status = TaskStatus.UNESTIMATED.name, author = users[3]
             },
             new ProjectTask()
             {
                 id = 4, title = "Sign up to an application", RoomId = 2999, estimate = 0, status = TaskStatus.UNESTIMATED.name, author = users[3]
             }
         };
         _context.ProjectTask.AddRange(tasks);
         _context.SaveChanges();
         tasks.ForEach(t => _context.Entry(t).State = EntityState.Detached);
     });
     "And having users assigned to the room"
     .x(() =>
     {
         participants = new List <RoomParticipant>();
         users.ForEach(u =>
         {
             if (u.id != 4)
             {
                 participants.Add(new RoomParticipant()
                 {
                     mailAddress = u.mailAddress, roomId = 2999
                 });
             }
         });
         _context.RoomParticipant.AddRange(participants);
         _context.SaveChanges();
     });
     "When I estimate all tasks"
     .x(async() =>
     {
         projectTasksController = new ProjectTasksController(_context);
         await projectTasksController.PatchProjectTaskEstimate(1, 1);
         await projectTasksController.PatchProjectTaskEstimate(2, 10);
         await projectTasksController.PatchProjectTaskEstimate(3, 5);
         await projectTasksController.PatchProjectTaskEstimate(4, 20);
     });
     "And request room summary"
     .x(async() =>
     {
         roomsController = new RoomsController(_context);
         summary         = await roomsController.GetGameSummary(2999);
     });
     "Then all tasks will be present"
     .x(() =>
     {
         tasks = _context.ProjectTask.Where(pt => pt.RoomId == 2999).ToList();
         tasks.ForEach(t =>
         {
             Assert.Contains(summary.tasks, (pt) => t.id == pt.id);
         });
     });
     "And all tasks will be having correct estimates"
     .x(() =>
     {
         tasks.ForEach(t =>
         {
             Assert.Contains(summary.tasks, (pt) => t.id == pt.id && t.estimate == pt.estimate);
         });
     });
     "And all participants will be present"
     .x(() =>
     {
         users.ForEach(u =>
         {
             if (u.mailAddress != summary.host)
             {
                 Assert.Contains(summary.participants, rp => rp.id == u.id);
             }
         });
     });
 }