public void Perform_review_submission_confirmation_for_a_data_deposit_project() { _project.SourceProjectType = SourceProjectType.DEPOSIT; _project.DataManagementPlan = null; // Arrange var vm = Builder<ConfirmDataDepositViewModel> .CreateNew() .With(o => o.ProjectId = _project.Id) .And(o => o.ProjectType = SourceProjectType.DEPOSIT) .Build(); _bus.When(c => c.Send(Arg.Any<Action<SiteRequestCommand>>())).Do(a => { // Arrange var command = new SiteRequestCommand(); var lambda = a.Arg<Action<SiteRequestCommand>>(); // Act lambda(command); // Assert Assert.That(command.ProjectId, Is.EqualTo(_project.Id), "Invalid project id passed to the bus"); Assert.That(command.ProjectTitle, Is.EqualTo(_project.Title), "Invalid project name passed to the bus"); Assert.That(command.ProjectDescription, Is.EqualTo(_project.Description), "Invalid project description passed to the bus"); foreach (var party in _project.Parties.Where(u => u.Role != AccessRole.None)) { Assert.That(command.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.ReviewDataDeposit(vm)).ShouldRedirectTo(_controller.GetType().GetMethod("SubmittedDataDeposit", new[] { typeof(int) })); _dataCollectionRepository.Received().Save(Arg.Any<DataCollection>()); }
public void Perform_review_submission_for_a_non_deposit_project() { // Arrange var vm = Builder<ConfirmDataManagementPlanViewModel> .CreateNew() .With(o => o.DataManagementPlanId = 1) .Build(); _project.SourceProjectType = PickHelper.RandomEnumExcept(SourceProjectType.DEPOSIT, SourceProjectType.None); _project.DataDeposit = null; // Act _projectRepository.GetByDataManagementPlanId(Arg.Is(vm.DataManagementPlanId)).Returns(_project); _bus.When(c => c.Send(Arg.Any<Action<SiteRequestCommand>>())) .Do(a => { var message = new SiteRequestCommand(); var lambda = a.Arg<Action<SiteRequestCommand>>(); lambda(message); Assert.That(message.ProjectId, Is.EqualTo(_project.Id), "Invalid project id passed to the bus"); Assert.That(message.ProjectDescription, Is.EqualTo(_project.Description), "Invalid project description passed to the bus"); Assert.That(message.ProjectTitle, Is.EqualTo(_project.Title), "Invalid project name passed to the bus"); }); // Assert _controller.WithCallTo(c => c.Review(vm)).ShouldRedirectTo(_controller.GetType().GetMethod("Submitted")); // Saving a new data collection _dataCollectionRepository.Received().Save(Arg.Any<DataCollection>()); _projectRepository.Received().GetByDataManagementPlanId(Arg.Is(vm.DataManagementPlanId)); }
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")); }