public void Submit_confirmation_for_DataManagementPlan_invokes_bus_send_request_site_collection_command() { // Arrange var vm = Builder <ConfirmDataManagementPlanViewModel> .CreateNew() .With(o => o.DataManagementPlanId = _project.DataManagementPlan.Id) .Build(); _bus.When(c => c.Send(Arg.Any <Action <SiteRequestCommand> >())).Do(a => { // Arrange var rsc = new SiteRequestCommand(); var lambda = a.Arg <Action <SiteRequestCommand> >(); // Act lambda(rsc); // Assert Assert.That(rsc.ProjectId, Is.EqualTo(_project.Id), "Invalid project id passed to the bus"); Assert.That(rsc.ProjectTitle, Is.EqualTo(_project.Title), "Invalid project name passed to the bus"); Assert.That(rsc.ProjectDescription, Is.EqualTo(_project.Description), "Invalid project description passed to the bus"); foreach (var party in _project.Parties.Where(p => p.Role != AccessRole.None)) { Assert.That(rsc.UserRoles.Any(u => u.Value.Contains(party.Party.UserId) && u.Key == party.Role.ToString()), "No site user passed to the bus for party " + party.Party.UserId); } }); // Assert _controller.WithCallTo(c => c.Review(vm)).ShouldRedirectTo(_controller.GetType().GetMethod("Submitted")); }
public void Save_DataDeposit_and_redirect_confirm_controller_confirm_action_on_post_to_New() { CreateUser(UserId); var user1 = Builder <UrdmsUser> .CreateNew().With(o => o.CurtinId = "123456A").Build(); _lookup.GetUser(Arg.Is(user1.CurtinId)).Returns(user1); var user2 = Builder <UrdmsUser> .CreateNew().With(o => o.CurtinId = "231231B").Build(); _lookup.GetUser(Arg.Is(user2.CurtinId)).Returns(user2); var user3 = Builder <UrdmsUser> .CreateNew().With(o => o.CurtinId = null).Build(); _lookup.GetUser(Arg.Is(user3.CurtinId)).Returns(user3); var vm = Builder <DataDepositViewModel> .CreateNew() .With(x => x.Id = 1) .And(x => x.PrincipalInvestigator = Builder <Party> .CreateNew().With(o => o.UserId = UserId).Build()) .And(x => x.UrdmsUsers = Builder <UrdmsUserViewModel> .CreateListOfSize(2) .TheFirst(1) .With(u => u.UserId = user1.CurtinId) .And(u => u.FullName = user1.FirstName) .TheNext(1) .With(u => u.UserId = user2.CurtinId) .And(u => u.FullName = user2.FirstName) .Build()) .And(x => x.NonUrdmsUsers = Builder <NonUrdmsUserViewModel> .CreateListOfSize(1) .TheFirst(1) .With(u => u.FullName = user3.FirstName) .Build()) .Build(); var project = Builder <Project> .CreateNew() .With(x => x.Id = 1) .And(x => x.Parties.Add(ProjectParty())) .And(x => x.SourceProjectType = SourceProjectType.DEPOSIT) .Build(); _projectRepository.Get(project.Id).Returns(project); _controller.WithCallTo(c => c.New(vm)).ShouldRedirectTo <ConfirmController>(_confirmController.GetType().GetMethod("ReviewDataDeposit", new[] { typeof(int) })); }