//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "adjust") public void test_adjust(int months, java.time.LocalDate date, java.time.LocalDate expected)
        public virtual void test_adjust(int months, LocalDate date, LocalDate expected)
        {
            TenorAdjustment test = TenorAdjustment.of(Tenor.ofMonths(months), LAST_DAY, BDA_FOLLOW_SAT_SUN);

            assertEquals(test.adjust(date, REF_DATA), expected);
            assertEquals(test.resolve(REF_DATA).adjust(date), expected);
        }
示例#2
0
 public virtual void test_of_notNegative()
 {
     assertThrowsIllegalArg(() => Tenor.of(Period.ofDays(-1)));
     assertThrowsIllegalArg(() => Tenor.ofDays(-1));
     assertThrowsIllegalArg(() => Tenor.ofWeeks(-1));
     assertThrowsIllegalArg(() => Tenor.ofMonths(-1));
     assertThrowsIllegalArg(() => Tenor.ofYears(-1));
 }
        //-------------------------------------------------------------------------
        public virtual void test_of_additionConventionNone()
        {
            TenorAdjustment test = TenorAdjustment.of(Tenor.of(Period.of(1, 2, 3)), PAC_NONE, BDA_NONE);

            assertEquals(test.Tenor, Tenor.of(Period.of(1, 2, 3)));
            assertEquals(test.AdditionConvention, PAC_NONE);
            assertEquals(test.Adjustment, BDA_NONE);
            assertEquals(test.ToString(), "1Y2M3D");
        }
 private TenorAdjustment(Tenor tenor, PeriodAdditionConvention additionConvention, BusinessDayAdjustment adjustment)
 {
     JodaBeanUtils.notNull(tenor, "tenor");
     JodaBeanUtils.notNull(additionConvention, "additionConvention");
     JodaBeanUtils.notNull(adjustment, "adjustment");
     this.tenor = tenor;
     this.additionConvention = additionConvention;
     this.adjustment         = adjustment;
     validate();
 }
示例#5
0
        //-------------------------------------------------------------------------
        public virtual void test_compare()
        {
            IList <Tenor> tenors = ImmutableList.of(Tenor.ofDays(1), Tenor.ofDays(3), Tenor.ofDays(7), Tenor.ofWeeks(2), Tenor.ofWeeks(4), Tenor.ofDays(30), Tenor.ofMonths(1), Tenor.ofDays(31), Tenor.of(Period.of(0, 1, 1)), Tenor.ofDays(60), Tenor.ofMonths(2), Tenor.ofDays(61), Tenor.ofDays(91), Tenor.ofMonths(3), Tenor.ofDays(92), Tenor.ofDays(182), Tenor.ofMonths(6), Tenor.ofDays(183), Tenor.ofDays(365), Tenor.ofYears(1), Tenor.ofDays(366));

            IList <Tenor> test = new List <Tenor>(tenors);

            Collections.shuffle(test);
            test.Sort();
            assertEquals(test, tenors);
        }
示例#6
0
 public virtual void test_of_int()
 {
     assertEquals(Tenor.ofDays(1), TENOR_1D);
     assertEquals(Tenor.ofDays(7), TENOR_1W);
     assertEquals(Tenor.ofWeeks(2), TENOR_2W);
     assertEquals(Tenor.ofMonths(1), TENOR_1M);
     assertEquals(Tenor.ofMonths(15), TENOR_15M);
     assertEquals(Tenor.ofMonths(18), TENOR_18M);
     assertEquals(Tenor.ofMonths(21), TENOR_21M);
     assertEquals(Tenor.ofYears(1), TENOR_1Y);
     assertEquals(Tenor.ofYears(35), TENOR_35Y);
     assertEquals(Tenor.ofYears(40), TENOR_40Y);
     assertEquals(Tenor.ofYears(45), TENOR_45Y);
     assertEquals(Tenor.ofYears(50), TENOR_50Y);
 }
示例#7
0
        //-------------------------------------------------------------------------
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @DataProvider(name = "based") public static Object[][] data_based()
        public static object[][] data_based()
        {
            return(new object[][]
            {
                new object[] { Tenor.ofDays(1), false, false },
                new object[] { Tenor.ofDays(2), false, false },
                new object[] { Tenor.ofDays(6), false, false },
                new object[] { Tenor.ofDays(7), true, false },
                new object[] { Tenor.ofWeeks(1), true, false },
                new object[] { Tenor.ofWeeks(3), true, false },
                new object[] { Tenor.ofMonths(1), false, true },
                new object[] { Tenor.ofMonths(3), false, true },
                new object[] { Tenor.ofYears(1), false, true },
                new object[] { Tenor.ofYears(3), false, true },
                new object[] { Tenor.of(Period.of(1, 2, 3)), false, false }
            });
        }
示例#8
0
        //-------------------------------------------------------------------------
        public virtual void test_equals_hashCode()
        {
            Tenor a1 = TENOR_3D;
            Tenor a2 = Tenor.ofDays(3);
            Tenor b  = TENOR_4M;

            assertEquals(a1.Equals(a1), true);
            assertEquals(a1.Equals(b), false);
            assertEquals(a1.Equals(a2), true);

            assertEquals(a2.Equals(a1), true);
            assertEquals(a2.Equals(a2), true);
            assertEquals(a2.Equals(b), false);

            assertEquals(b.Equals(a1), false);
            assertEquals(b.Equals(a2), false);
            assertEquals(b.Equals(b), true);

            assertEquals(a1.GetHashCode(), a2.GetHashCode());
        }
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 110246592:         // tenor
                    this.tenor_Renamed = (Tenor)newValue;
                    break;

                case 1652975501:         // additionConvention
                    this.additionConvention_Renamed = (PeriodAdditionConvention)newValue;
                    break;

                case 1977085293:         // adjustment
                    this.adjustment_Renamed = (BusinessDayAdjustment)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
示例#10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "based") public void test_isMonthBased(Tenor test, boolean weekBased, boolean monthBased)
        public virtual void test_isMonthBased(Tenor test, bool weekBased, bool monthBased)
        {
            assertEquals(test.MonthBased, monthBased);
        }
示例#11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "normalized") public void test_normalized(java.time.Period period, java.time.Period normalized)
        public virtual void test_normalized(Period period, Period normalized)
        {
            assertEquals(Tenor.of(period).normalized().Period, normalized);
        }
示例#12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "parseBad", expectedExceptions = IllegalArgumentException.class) public void test_parse_String_bad(String input)
        public virtual void test_parse_String_bad(string input)
        {
            Tenor.parse(input);
        }
 //-----------------------------------------------------------------------
 /// <summary>
 /// Sets the tenor to be added.
 /// <para>
 /// When the adjustment is performed, this tenor will be added to the input date.
 /// </para>
 /// </summary>
 /// <param name="tenor">  the new value, not null </param>
 /// <returns> this, for chaining, not null </returns>
 public Builder tenor(Tenor tenor)
 {
     JodaBeanUtils.notNull(tenor, "tenor");
     this.tenor_Renamed = tenor;
     return(this);
 }
示例#14
0
 //-------------------------------------------------------------------------
 public virtual void test_parse_String_roundTrip()
 {
     assertEquals(Tenor.parse(TENOR_10M.ToString()), TENOR_10M);
 }
示例#15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "ofYears") public void test_ofYears(int years, java.time.Period stored, String str)
        public virtual void test_ofYears(int years, Period stored, string str)
        {
            assertEquals(Tenor.ofYears(years).Period, stored);
            assertEquals(Tenor.ofYears(years).ToString(), str);
        }
示例#16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "ofMonths") public void test_ofMonths(int months, java.time.Period stored, String str)
        public virtual void test_ofMonths(int months, Period stored, string str)
        {
            assertEquals(Tenor.ofMonths(months).Period, stored);
            assertEquals(Tenor.ofMonths(months).ToString(), str);
        }
示例#17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "ofPeriod") public void test_ofPeriod(java.time.Period period, java.time.Period stored, String str)
        public virtual void test_ofPeriod(Period period, Period stored, string str)
        {
            assertEquals(Tenor.of(period).Period, stored);
            assertEquals(Tenor.of(period).ToString(), str);
        }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance that can adjust a date by the specified tenor.
 /// <para>
 /// When adjusting a date, the specified tenor is added to the input date.
 /// The business day adjustment will then be used to ensure the result is a valid business day.
 ///
 /// </para>
 /// </summary>
 /// <param name="tenor">  the tenor to add to the input date </param>
 /// <param name="additionConvention">  the convention used to perform the addition </param>
 /// <param name="adjustment">  the business day adjustment to apply to the result of the addition </param>
 /// <returns> the tenor adjustment </returns>
 public static TenorAdjustment of(Tenor tenor, PeriodAdditionConvention additionConvention, BusinessDayAdjustment adjustment)
 {
     return(new TenorAdjustment(tenor, additionConvention, adjustment));
 }
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(TenorAdjustment beanToCopy)
 {
     this.tenor_Renamed = beanToCopy.Tenor;
     this.additionConvention_Renamed = beanToCopy.AdditionConvention;
     this.adjustment_Renamed         = beanToCopy.Adjustment;
 }
 /// <summary>
 /// Obtains an instance that can adjust a date by the specified tenor using the
 /// last business day of month convention.
 /// <para>
 /// When adjusting a date, the specified tenor is added to the input date.
 /// The business day adjustment will then be used to ensure the result is a valid business day.
 /// </para>
 /// <para>
 /// The period must consist only of months and/or years.
 ///
 /// </para>
 /// </summary>
 /// <param name="tenor">  the tenor to add to the input date </param>
 /// <param name="adjustment">  the business day adjustment to apply to the result of the addition </param>
 /// <returns> the tenor adjustment </returns>
 public static TenorAdjustment ofLastBusinessDay(Tenor tenor, BusinessDayAdjustment adjustment)
 {
     return(new TenorAdjustment(tenor, PeriodAdditionConventions.LAST_BUSINESS_DAY, adjustment));
 }
示例#21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "parseGood") public void test_parse_String_good_withP(String input, Tenor expected)
        public virtual void test_parse_String_good_withP(string input, Tenor expected)
        {
            assertEquals(Tenor.parse("P" + input), expected);
        }