public void Setup()
        {

            Test.Initialize();


            _now = DateTime.Now;

            _submitForApprovalMessage = new SubmitForApproval
                        {
                            ApprovedBy = "GH13579",
                            ApprovedOn = _now,
                            DataCollectionId = 1
                        };

            _submitForSecondaryApprovalMessage = new SubmitForSecondaryApproval
                        {
                            DataCollectionId = 1,
                            ApprovedBy = "FH13545",
                            ApprovedOn = _submitForApprovalMessage.ApprovedOn.AddDays(1)
                        };

            _submitForFinalApprovalMessage = new SubmitForFinalApproval
                        {
                            DataCollectionId = 1,
                            ApprovedBy = "787878r",
                            ApprovedOn = _submitForSecondaryApprovalMessage.ApprovedOn.AddDays(1)
                        };

            _submitForSecondaryReApprovalMessage = new SubmitForSecondaryReApproval
            {
                DataCollectionId = 1,
                ApprovedBy = "454545k",
                ApprovedOn = _submitForFinalApprovalMessage.ApprovedOn.AddDays(1)
            };


            _publishDataCollectionMessage = new PublishDataCollection
                                                {
                                                    DataCollectionId = 1,
                                                    ApprovedBy = "321312w",
                                                    ApprovedOn = _submitForFinalApprovalMessage.ApprovedOn.AddDays(2)
                                                };

            _exportToVivoResponse = new ExportToVivoResponse
                                        {
                                            DataCollectionId = 1
                                        };

        }
        public void Send_SubmitForOrdReApproval_command_to_bus_for_a_secondary_approved_data_collection_if_changes_have_been_made()
        {
            // Qa has made changes to the data collection so must be advised that it will return to secondary for reapproval
            var dataCollection = CreateDataCollectionWithState(DataCollectionStatus.SecondaryApproved);
            dataCollection.Title = "No changes yet";
            var vm = Builder<ApprovalConfirmationViewModel>.CreateNew()
                .With(m => m.DataCollectionId = dataCollection.Id)
                .And(m => m.State = DataCollectionStatus.SecondaryApproved)
                .Build();
            var oldHashCode = new DataCollectionHashCode();
            oldHashCode.UpdateHashCode(dataCollection);
            CreateQaUser();

            dataCollection.Title = "We've made a change";
            _dataCollectionRepository.Get(dataCollection.Id).Returns(dataCollection);
            _hashCodeRepository.GetByDataCollectionId(dataCollection.Id).Returns(oldHashCode);

			_bus.When(c => c.Send(Arg.Any<Action<SubmitForSecondaryApproval>>())).Do(a =>
            {
				var rsc = new SubmitForSecondaryApproval();
				var lambda = a.Arg<Action<SubmitForSecondaryApproval>>();

                lambda(rsc);

                Assert.That(rsc.DataCollectionId, Is.EqualTo(dataCollection.Id), "Invalid data collection id passed to the bus");
                Assert.That(rsc.ApprovedOn, Is.EqualTo(dataCollection.CurrentState.StateChangedOn).Within(1).Minutes, "Invalid approval date passed to the bus");
                Assert.That(rsc.ApprovedBy, Is.EqualTo(QaId), "Invalid approver id passed to the bus");
            });

            _controller.WithCallTo(c => c.SubmitForReapproval(vm)).ShouldRedirectTo(x => x.Index);
			_bus.Received().Send(Arg.Any<Action<SubmitForSecondaryApproval>>());
            _hashCodeRepository.Received().Delete(oldHashCode);
        }
        public void Send_SubmitForOrdApproval_command_to_bus_for_a_submitted_data_collection_once_qa_approved()
        {
            // QA actions to qa approve the data collection (should pass on to secondary approver)
            var dataCollection = CreateDataCollectionWithState(DataCollectionStatus.Submitted);
            var vm = Builder<ApprovalConfirmationViewModel>.CreateNew()
                .With(m => m.DataCollectionId = dataCollection.Id)
                .And(m => m.State = DataCollectionStatus.Submitted)
                .And(m => m.IsQaApproved = true)
                .Build();
            var hashCode = new DataCollectionHashCode();
            hashCode.UpdateHashCode(dataCollection);
            CreateQaUser();

            _dataCollectionRepository.Get(dataCollection.Id).Returns(dataCollection);
            _hashCodeRepository.GetByDataCollectionId(dataCollection.Id).Returns(hashCode);
            
            _bus.When(c => c.Send(Arg.Any<Action<SubmitForSecondaryApproval>>())).Do(a =>
            {
                // Arrange
				var rsc = new SubmitForSecondaryApproval();
				var lambda = a.Arg<Action<SubmitForSecondaryApproval>>();

                // Act
                lambda(rsc);

                // Assert
                Assert.That(rsc.DataCollectionId, Is.EqualTo(dataCollection.Id), "Invalid data collection id passed to the bus");
                Assert.That(rsc.ApprovedOn, Is.EqualTo(dataCollection.CurrentState.StateChangedOn).Within(1).Minutes, "Invalid approval date passed to the bus");
                Assert.That(rsc.ApprovedBy, Is.EqualTo(QaId), "Invalid approver id passed to the bus");
            });

            _controller.WithCallTo(c => c.Confirm(vm)).ShouldRenderView("Approved")
                .WithModel<ApprovalConfirmationViewModel>(m => m.ProposedState == DataCollectionStatus.QaApproved);
        }