コード例 #1
0
 public CommitmentListItem MapFrom(CommitmentSummary source, CallerType callerType)
 {
     return(new CommitmentListItem
     {
         Id = source.Id,
         Reference = source.Reference,
         ProviderId = source.ProviderId,
         ProviderName = source.ProviderName,
         EmployerAccountId = source.EmployerAccountId,
         LegalEntityId = source.LegalEntityId,
         LegalEntityName = source.LegalEntityName,
         CommitmentStatus = (Types.Commitment.Types.CommitmentStatus)source.CommitmentStatus,
         EditStatus = (Types.Commitment.Types.EditStatus)source.EditStatus,
         ApprenticeshipCount = source.ApprenticeshipCount,
         AgreementStatus = (Types.AgreementStatus)source.AgreementStatus,
         LastAction = (Types.Commitment.Types.LastAction)source.LastAction,
         CanBeApproved = callerType == CallerType.Employer
                 ? source.EmployerCanApproveCommitment
                 : source.ProviderCanApproveCommitment,
         EmployerLastUpdateInfo =
             new LastUpdateInfo {
             Name = source.LastUpdatedByEmployerName, EmailAddress = source.LastUpdatedByEmployerEmail
         },
         ProviderLastUpdateInfo =
             new LastUpdateInfo {
             Name = source.LastUpdatedByProviderName, EmailAddress = source.LastUpdatedByProviderEmail
         },
         Messages = MapMessagesFrom(source.Messages)
     });
 }
        public void ThenBasicMappingIsCorrect(CommitmentSummary commitmentSummary)
        {
            var untouched = Clone(commitmentSummary);

            var commitmentListItem = _mapper.MapFrom(commitmentSummary, CallerType.Employer);

            Assert.AreEqual(untouched.Id, commitmentListItem.Id);
            Assert.AreEqual(untouched.Reference, commitmentListItem.Reference);
            Assert.AreEqual(untouched.ProviderId, commitmentListItem.ProviderId);
            Assert.AreEqual(untouched.ProviderName, commitmentListItem.ProviderName);
            Assert.AreEqual(untouched.EmployerAccountId, commitmentListItem.EmployerAccountId);
            Assert.AreEqual(untouched.LegalEntityId, commitmentListItem.LegalEntityId);
            Assert.AreEqual(untouched.LegalEntityName, commitmentListItem.LegalEntityName);
            Assert.AreEqual((Types.Commitment.Types.CommitmentStatus)untouched.CommitmentStatus, commitmentListItem.CommitmentStatus);
            Assert.AreEqual((Types.Commitment.Types.EditStatus)untouched.EditStatus, commitmentListItem.EditStatus);
            Assert.AreEqual(untouched.ApprenticeshipCount, commitmentListItem.ApprenticeshipCount);
            Assert.AreEqual((Types.AgreementStatus)untouched.AgreementStatus, commitmentListItem.AgreementStatus);
            Assert.AreEqual((Types.Commitment.Types.LastAction)untouched.LastAction, commitmentListItem.LastAction);
            Assert.AreEqual(untouched.TransferSenderId, commitmentListItem.TransferSenderId);
            Assert.AreEqual((Types.TransferApprovalStatus)untouched.TransferApprovalStatus, commitmentListItem.TransferApprovalStatus);
            Assert.AreEqual(untouched.TransferSenderName, commitmentListItem.TransferSenderName);

            Assert.IsNotNull(commitmentListItem.EmployerLastUpdateInfo);
            Assert.AreEqual(untouched.LastUpdatedByEmployerName, commitmentListItem.EmployerLastUpdateInfo.Name);
            Assert.AreEqual(untouched.LastUpdatedByEmployerEmail, commitmentListItem.EmployerLastUpdateInfo.EmailAddress);

            Assert.IsNotNull(commitmentListItem.ProviderLastUpdateInfo);
            Assert.AreEqual(untouched.LastUpdatedByProviderName, commitmentListItem.ProviderLastUpdateInfo.Name);
            Assert.AreEqual(untouched.LastUpdatedByProviderEmail, commitmentListItem.ProviderLastUpdateInfo.EmailAddress);

            Assert.IsNotNull(commitmentListItem.Messages);
            Assert.AreEqual(untouched.Messages.Count, commitmentListItem.Messages.Count);
        }
        public void ThenCanBeApprovedIsMappedAccordingToCallerType(bool expectedCanBeApproved,
                                                                   CallerType callerType, bool employerCanApprove, bool providerCanApprove)
        {
            var commitmentSummary = new CommitmentSummary
            {
                EmployerCanApproveCommitment = employerCanApprove,
                ProviderCanApproveCommitment = providerCanApprove,
                Messages = new List <Message>()
            };

            var commitmentListItem = _mapper.MapFrom(commitmentSummary, callerType);

            Assert.AreEqual(expectedCanBeApproved, commitmentListItem.CanBeApproved);
        }