Ejemplo n.º 1
0
        public void Convert_PaymentRequest_Contract_Status_To_PaymentRequest_Model_Status_OK()
        {
            // arrange
            var error = PaymentRequestProcessingError.PaymentExpired;

            var values = Enum.GetValues(typeof(PaymentRequestStatus))
                         .Cast <PaymentRequestStatus>()
                         .Where(o => o != PaymentRequestStatus.None)
                         .ToList();

            // act

            foreach (var value in values)
            {
                StatusConverter.Convert(value, error);
            }

            // assert
            Assert.IsTrue(true);
        }
Ejemplo n.º 2
0
        public void TestStatusConverter()
        {
            var converter = new StatusConverter();

            Assert.AreEqual(string.Empty, converter.Convert(null, typeof(Tamagotchi), new object(), CultureInfo.CurrentCulture));

            Assert.AreEqual("Deceased", converter.Convert(new Tamagotchi {
                Deceased = true
            }, typeof(Tamagotchi), new object(), CultureInfo.CurrentCulture));

            Assert.AreEqual("Sleep\r\nHug", converter.Convert(new  Tamagotchi
            {
                Statuses = new List <string> {
                    "Sleep", "Hug"
                }
            }, typeof(Tamagotchi), new object(), CultureInfo.CurrentCulture));

            Assert.AreEqual(string.Empty, converter.Convert(new Tamagotchi {
                Statuses = new List <string>()
            }, typeof(Tamagotchi), new object(), CultureInfo.CurrentCulture));
        }
Ejemplo n.º 3
0
        public AutoMapperProfile()
        {
            CreateMap <InvoiceUpdateMessage, Contract.Invoice.InvoiceUpdateMessage>(MemberList.Destination)
            .ForMember(dest => dest.Status, opt => opt.MapFrom(src => src.Status.ToString()));

            CreateMap <Invoice, InvoiceModel>(MemberList.Source)
            .ForSourceMember(src => src.TotalPaidAmountInSettlementAsset, opt => opt.Ignore())
            .ForSourceMember(src => src.HasMultiplePaymentRequests, opt => opt.Ignore());

            CreateMap <CreateInvoiceModel, Invoice>(MemberList.Destination)
            .ForMember(dest => dest.Id, opt => opt.Ignore())
            .ForMember(dest => dest.Status, opt => opt.Ignore())
            .ForMember(dest => dest.PaidAmount, opt => opt.Ignore())
            .ForMember(dest => dest.PaymentRequestId, opt => opt.Ignore())
            .ForMember(dest => dest.CreatedDate, opt => opt.Ignore())
            .ForMember(dest => dest.TotalPaidAmountInSettlementAsset, opt => opt.Ignore())
            .ForMember(dest => dest.LeftAmountToPayInSettlementAsset, opt => opt.Ignore())
            .ForMember(dest => dest.HasMultiplePaymentRequests, opt => opt.Ignore());

            CreateMap <UpdateInvoiceModel, Invoice>(MemberList.Destination)
            .ForMember(dest => dest.Status, opt => opt.Ignore())
            .ForMember(dest => dest.PaidAmount, opt => opt.Ignore())
            .ForMember(dest => dest.PaymentRequestId, opt => opt.Ignore())
            .ForMember(dest => dest.CreatedDate, opt => opt.Ignore())
            .ForMember(dest => dest.TotalPaidAmountInSettlementAsset, opt => opt.Ignore())
            .ForMember(dest => dest.LeftAmountToPayInSettlementAsset, opt => opt.Ignore())
            .ForMember(dest => dest.HasMultiplePaymentRequests, opt => opt.Ignore());

            CreateMap <FileInfo, FileInfoModel>(MemberList.Source)
            .ForSourceMember(src => src.InvoiceId, opt => opt.Ignore());

            CreateMap <Employee, EmployeeModel>(MemberList.Source);

            CreateMap <CreateEmployeeModel, Employee>(MemberList.Destination)
            .ForMember(dest => dest.Id, opt => opt.Ignore())
            .ForMember(dest => dest.IsDeleted, opt => opt.UseValue(false));

            CreateMap <RegisterEmployeeCommand, Employee>(MemberList.Destination)
            .ForMember(dest => dest.Id, opt => opt.Ignore())
            .ForMember(dest => dest.IsBlocked, opt => opt.UseValue(false))
            .ForMember(dest => dest.IsDeleted, opt => opt.UseValue(false))
            .ForMember(dest => dest.IsInternalSupervisor, opt => opt.UseValue(false));

            CreateMap <UpdateEmployeeCommand, Employee>(MemberList.Destination)
            .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.EmployeeId))
            .ForMember(dest => dest.IsDeleted, opt => opt.UseValue(false));

            CreateMap <UpdateEmployeeModel, Employee>(MemberList.Destination)
            .ForMember(dest => dest.IsDeleted, opt => opt.UseValue(false));

            CreateMap <HistoryItem, HistoryItemModel>(MemberList.Source);

            CreateMap <SetMerchantSettingModel, MerchantSetting>(MemberList.Source);

            CreateMap <PaymentRequestDetailsMessage, InvoiceStatusUpdateNotification>(MemberList.Destination)
            .ForMember(dest => dest.PaymentRequestId, opt => opt.MapFrom(src => src.Id))
            .ForMember(dest => dest.Amount, opt => opt.MapFrom(src => src.PaidAmount))
            .ForMember(dest => dest.AssetId, opt => opt.MapFrom(src => src.PaymentAssetId))
            .ForMember(dest => dest.Status,
                       opt => opt.MapFrom(src => StatusConverter.Convert(src.Status, src.ProcessingError)))
            .ForMember(dest => dest.Date, opt => opt.MapFrom(src => src.PaidDate ?? DateTime.UtcNow));
        }
 public StatusConverterTests()
 {
     instance = new StatusConverter();
 }
Ejemplo n.º 5
0
        public void TestStatusConverterBackFails()
        {
            var converter = new StatusConverter();

            converter.ConvertBack(null, typeof(Tamagotchi), new object(), CultureInfo.CurrentCulture);
        }