コード例 #1
0
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            var payment = (PaymentViewModel)value;

            if (payment == null)
            {
                return(string.Empty);
            }

            return(PaymentAmountConverterLogic.GetAmountSign(payment));
        }
コード例 #2
0
 public void Converter_Payment_PositiveAmountSign()
 {
     CultureHelper.CurrentCulture = CultureInfo.CurrentCulture;
     PaymentAmountConverterLogic
     .GetFormattedAmountString(new PaymentViewModel(mediatorMock.Object, navigationService.Object)
     {
         Amount = 80, Type = PaymentType.Income
     },
                               string.Empty)
     .ShouldEqual($"+ {80:C}");
 }
コード例 #3
0
 public void Converter_Payment_NegativeAmountSign()
 {
     CultureHelper.CurrentCulture = new CultureInfo("en-US");
     PaymentAmountConverterLogic
     .GetFormattedAmountString(new PaymentViewModel(mediatorMock.Object, navigationService.Object)
     {
         Amount = 80, Type = PaymentType.Expense
     }, string.Empty)
     .ShouldEqual($"- $80.00");
     CultureHelper.CurrentCulture = CultureInfo.CurrentCulture;
 }
コード例 #4
0
        public void GetCorrectSignForExpenseAndIncome(PaymentType type, string expectedResult, int chargedAccountId, int currentAccountId)
        {
            // Arrange
            var payment = new PaymentViewModel {
                Type = type, ChargedAccountId = chargedAccountId, CurrentAccountId = currentAccountId
            };

            // Act
            string result = PaymentAmountConverterLogic.GetAmountSign(payment);

            // Assert
            result.Should().StartWith(expectedResult);
        }
コード例 #5
0
        public void Converter_TransferSameAccount_Plus()
        {
            CultureHelper.CurrentCulture = CultureInfo.CurrentCulture;
            var account = new AccountViewModel
            {
                Id             = 4,
                CurrentBalance = 400
            };

            PaymentAmountConverterLogic.GetFormattedAmountString(new PaymentViewModel(mediatorMock.Object, navigationService.Object)
            {
                Amount           = 80,
                Type             = PaymentType.Transfer,
                ChargedAccount   = new AccountViewModel(),
                CurrentAccountId = account.Id
            }, string.Empty)
            .ShouldEqual($"+ {80:C}");
        }
コード例 #6
0
 /// <summary>
 ///     Adds a plus or a minus to the payment amont on the UI based on if it is a income or a expense
 /// </summary>
 /// <param name="value">PaymentViewModel to convert..</param>
 /// <param name="targetType">Not used.</param>
 /// <param name="parameter">Ignore transfer parameter.</param>
 /// <param name="culture">Not used..</param>
 /// <returns>The convert.</returns>
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     return(PaymentAmountConverterLogic.GetFormattedAmountString(value as PaymentViewModel, parameter as string));
 }