예제 #1
0
        //-------------------------------------------------------------------------
        public virtual void test_of()
        {
            LocalDateDoublePoint test = LocalDateDoublePoint.of(DATE_2012_06_30, 1d);

            assertEquals(test.Date, DATE_2012_06_30);
            assertEquals(test.Value, 1d, TOLERANCE);
        }
예제 #2
0
        public virtual void test_equalsBad()
        {
            LocalDateDoublePoint a = LocalDateDoublePoint.of(DATE_2012_06_29, 1d);

            assertEquals(a.Equals(ANOTHER_TYPE), false);
            assertEquals(a.Equals(null), false);
        }
예제 #3
0
        public virtual void test_withValue()
        {
            LocalDateDoublePoint @base = LocalDateDoublePoint.of(DATE_2012_06_30, 1d);
            LocalDateDoublePoint test  = @base.withValue(2d);

            assertEquals(test.Date, DATE_2012_06_30);
            assertEquals(test.Value, 2d, TOLERANCE);
        }
예제 #4
0
        public virtual void test_merge_point()
        {
            LocalDateDoubleTimeSeriesBuilder test = LocalDateDoubleTimeSeries.builder();

            test.put(date(2013, 1, 1), 2d);
            test.merge(LocalDateDoublePoint.of(date(2013, 1, 1), 3d), double?.sum);

            assertEquals(test.get(date(2013, 1, 1)), double?.of(5d));
        }
        //-------------------------------------------------------------------------
        public virtual void test_stream()
        {
            LocalDateDoubleTimeSeries @base = LocalDateDoubleTimeSeries.builder().putAll(DATES_2010_12, VALUES_10_12).build();

            object[] test = @base.ToArray();
            assertEquals(test[0], LocalDateDoublePoint.of(DATE_2010_01_01, 10));
            assertEquals(test[1], LocalDateDoublePoint.of(DATE_2011_01_01, 11));
            assertEquals(test[2], LocalDateDoublePoint.of(DATE_2012_01_01, 12));
        }
        public virtual void test_immutableValuesViaBeanGet()
        {
            LocalDateDoubleTimeSeries test = LocalDateDoubleTimeSeries.builder().putAll(DATES_2010_12, VALUES_10_12).build();

            double[] array = (double[])((Bean)test).property("values").get();
            array[0] = -1;
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
            LocalDateDoublePoint[] points = test.ToArray(LocalDateDoublePoint[] ::new);
            assertEquals(points[0], LocalDateDoublePoint.of(DATE_2010_01_01, 10d));
            assertEquals(points[1], LocalDateDoublePoint.of(DATE_2011_01_01, 11d));
            assertEquals(points[2], LocalDateDoublePoint.of(DATE_2012_01_01, 12d));
        }
예제 #7
0
        //-------------------------------------------------------------------------
        public virtual void test_equalsHashCode_differentDates()
        {
            LocalDateDoublePoint a1 = LocalDateDoublePoint.of(DATE_2012_06_29, 1d);
            LocalDateDoublePoint a2 = LocalDateDoublePoint.of(DATE_2012_06_29, 1d);
            LocalDateDoublePoint b  = LocalDateDoublePoint.of(DATE_2012_06_30, 1d);
            LocalDateDoublePoint c  = LocalDateDoublePoint.of(DATE_2012_07_01, 1d);

            assertEquals(a1.Equals(a1), true);
            assertEquals(a1.Equals(a2), true);
            assertEquals(a1.Equals(b), false);
            assertEquals(a1.Equals(c), false);
            assertEquals(a1.GetHashCode(), a1.GetHashCode());
        }
예제 #8
0
        //-------------------------------------------------------------------------
        public virtual void test_compareTo()
        {
            LocalDateDoublePoint a = LocalDateDoublePoint.of(DATE_2012_06_29, 1d);
            LocalDateDoublePoint b = LocalDateDoublePoint.of(DATE_2012_06_30, 1d);
            LocalDateDoublePoint c = LocalDateDoublePoint.of(DATE_2012_07_01, 1d);

            assertTrue(a.CompareTo(a) == 0);
            assertTrue(a.CompareTo(b) < 0);
            assertTrue(a.CompareTo(c) < 0);
            assertTrue(b.CompareTo(a) > 0);
            assertTrue(b.CompareTo(b) == 0);
            assertTrue(b.CompareTo(c) < 0);
            assertTrue(c.CompareTo(a) > 0);
            assertTrue(c.CompareTo(b) > 0);
            assertTrue(c.CompareTo(c) == 0);
        }
        //-------------------------------------------------------------------------
        public virtual void test_of_collection()
        {
            ICollection <LocalDateDoublePoint> points = Arrays.asList(LocalDateDoublePoint.of(DATE_2011_01_01, 2d), LocalDateDoublePoint.of(DATE_2012_01_01, 3d));
            LocalDateDoubleTimeSeries          test   = LocalDateDoubleTimeSeries.builder().putAll(points.stream()).build();

            assertEquals(test.Empty, false);
            assertEquals(test.size(), 2);
            assertEquals(test.containsDate(DATE_2010_01_01), false);
            assertEquals(test.containsDate(DATE_2011_01_01), true);
            assertEquals(test.containsDate(DATE_2012_01_01), true);
            assertEquals(test.get(DATE_2010_01_01), double?.empty());
            assertEquals(test.get(DATE_2011_01_01), double?.of(2d));
            assertEquals(test.get(DATE_2012_01_01), double?.of(3d));
            assertEquals(test.dates().toArray(), new object[] { DATE_2011_01_01, DATE_2012_01_01 });
            assertEquals(test.values().toArray(), new double[] { 2d, 3d });
        }
        //-------------------------------------------------------------------------
        public virtual void test_immutableViaBeanBuilder()
        {
            LocalDate[] dates  = new LocalDate[] { DATE_2010_01_01, DATE_2011_01_01, DATE_2012_01_01 };
            double[]    values = new double[] { 6, 5, 4 };
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.joda.beans.BeanBuilder<? extends LocalDateDoubleTimeSeries> builder = SparseLocalDateDoubleTimeSeries.meta().builder();
            BeanBuilder <LocalDateDoubleTimeSeries> builder = SparseLocalDateDoubleTimeSeries.meta().builder();

            builder.set("dates", dates);
            builder.set("values", values);
            LocalDateDoubleTimeSeries test = builder.build();

            dates[0]  = DATE_2012_01_01;
            values[0] = -1;
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
            LocalDateDoublePoint[] points = test.ToArray(LocalDateDoublePoint[] ::new);
            assertEquals(points[0], LocalDateDoublePoint.of(DATE_2010_01_01, 6d));
            assertEquals(points[1], LocalDateDoublePoint.of(DATE_2011_01_01, 5d));
            assertEquals(points[2], LocalDateDoublePoint.of(DATE_2012_01_01, 4d));
        }
 //-------------------------------------------------------------------------
 public Stream <LocalDateDoublePoint> stream()
 {
     return(IntStream.range(0, size()).mapToObj(i => LocalDateDoublePoint.of(dates_Renamed[i], values_Renamed[i])));
 }
 /// <summary>
 /// Merges the specified date/value point into this builder.
 /// <para>
 /// The operator is invoked if the date already exists.
 ///
 /// </para>
 /// </summary>
 /// <param name="point">  the point to be added </param>
 /// <param name="operator">  the operator to use for merging </param>
 /// <returns> this builder </returns>
 public LocalDateDoubleTimeSeriesBuilder merge(LocalDateDoublePoint point, System.Func <double, double, double> @operator)
 {
     ArgChecker.notNull(point, "point");
     entries.merge(point.Date, point.Value, (a, b) => @operator(a, b));
     return(this);
 }
예제 #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expectedExceptions = IllegalArgumentException.class) public void test_withDate_nullDate()
        public virtual void test_withDate_nullDate()
        {
            LocalDateDoublePoint @base = LocalDateDoublePoint.of(DATE_2012_06_30, 1d);

            @base.withDate(null);
        }
예제 #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expectedExceptions = IllegalArgumentException.class) public void test_of_nullDate()
        public virtual void test_of_nullDate()
        {
            LocalDateDoublePoint.of(null, 1d);
        }
 private Stream <LocalDateDoublePoint> streamEntries()
 {
     return(entries.SetOfKeyValuePairs().Select(e => LocalDateDoublePoint.of(e.Key, e.Value)));
 }
예제 #16
0
        //-------------------------------------------------------------------------
        public virtual void test_toString()
        {
            LocalDateDoublePoint test = LocalDateDoublePoint.of(DATE_2012_06_29, 1d);

            assertEquals(test.ToString(), "(2012-06-29=1.0)");
        }
 /// <summary>
 /// Puts the specified date/value point into this builder.
 /// </summary>
 /// <param name="point">  the point to be added </param>
 /// <returns> this builder </returns>
 public LocalDateDoubleTimeSeriesBuilder put(LocalDateDoublePoint point)
 {
     ArgChecker.notNull(point, "point");
     put(point.Date, point.Value);
     return(this);
 }
        public virtual void test_of_collection_collectionWithNull()
        {
            ICollection <LocalDateDoublePoint> points = Arrays.asList(LocalDateDoublePoint.of(DATE_2011_01_01, 2d), null);

            assertThrowsIllegalArg(() => LocalDateDoubleTimeSeries.builder().putAll(points.stream()).build());
        }