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 Redirect_to_confirm_on_post_to_step2() { var dataCollection = Builder <DataCollection> .CreateNew() .With(o => o.CurrentState = Builder <DataCollectionState> .CreateNew() .WithConstructor(() => new DataCollectionState(DataCollectionStatus.SecondaryApproved, DateTime.Now)).Build()) .Build(); CreateQaUser(); _dataCollectionRepository.Get(dataCollection.Id).Returns(dataCollection); var model = Builder <DataCollectionApprovalViewModelStep2> .CreateNew() .With(vm => vm.Id = dataCollection.Id) .Build(); _controller.WithCallTo(c => c.Step2(model)).ShouldRedirectTo(_controller.GetType().GetMethod("Confirm", new[] { typeof(Int32) })); _dataCollectionRepository.Received().Save(dataCollection); }
public void Update_status_of_the_data_management_plan_when_a_site_when_the_status_of_provisioning_changes() { var handler = new ViewModelUpdaterHandler(_repository); _repository.UpdateStatusByProjectId(Arg.Any <int>(), Arg.Any <int>(), Arg.Any <string>(), Arg.Any <int>()); Test.Handler(handler) .OnMessage <ProvisioningStatusChanged>(m => { m.ProjectId = 1; m.SiteUrl = "http://mydomain.org"; m.RequestId = 1; m.ProvisioningRequestStatusId = 1; }); _repository.Received().UpdateStatusByProjectId(Arg.Any <int>(), Arg.Any <int>(), Arg.Any <string>(), Arg.Any <int>()); }
public void Send_a_export_to_vivo_response_on_message_of_export_to_vivo_message() { var handler = new ExportToVivoHandler(_vivoDataCollectionRepository, _dataCollectionRepository); _dataCollectionRepository.Get(Arg.Is(1)); Test.Handler(handler) .ExpectReply <ExportToVivoResponse>(m => m.DataCollectionId == 1) .OnMessage <ExportToVivo>(m => { m.DataCollectionId = 1; }); _dataCollectionRepository.Received().Get(Arg.Is(1)); _vivoDataCollectionRepository.Received().Save(Arg.Any <DataCollection>()); }