public virtual void test_scenarios()
        {
            RepeatedScenarioMarketData test = RepeatedScenarioMarketData.of(2, BASE_DATA);

            assertEquals(test.scenarios().count(), 2);
            test.scenarios().forEach(md => assertSame(md, BASE_DATA));
        }
        /// <summary>
        /// Tests the combinedWith method when the other set of market data is not an instance of ImmutableScenarioMarketData
        /// </summary>
        public virtual void test_combinedWithDifferentImpl()
        {
            LocalDateDoubleTimeSeries timeSeries1 = LocalDateDoubleTimeSeries.builder().put(date(2011, 3, 8), 1).put(date(2011, 3, 9), 2).put(date(2011, 3, 10), 3).build();

            LocalDateDoubleTimeSeries timeSeries2 = LocalDateDoubleTimeSeries.builder().put(date(2011, 3, 8), 10).put(date(2011, 3, 9), 20).put(date(2011, 3, 10), 30).build();

            LocalDateDoubleTimeSeries timeSeries2a = LocalDateDoubleTimeSeries.builder().put(date(2011, 3, 8), 1000).put(date(2011, 3, 9), 2000).put(date(2011, 3, 10), 3000).build();

            LocalDateDoubleTimeSeries timeSeries3 = LocalDateDoubleTimeSeries.builder().put(date(2011, 3, 8), 100).put(date(2011, 3, 9), 200).put(date(2011, 3, 10), 300).build();

            MarketData marketData = ImmutableMarketData.builder(LocalDate.of(2011, 3, 8)).addTimeSeries(TEST_ID1, timeSeries1).addTimeSeries(TEST_ID2, timeSeries2).addValue(TEST_ID1, 1.1).addValue(TEST_ID2, 1.2).build();

            RepeatedScenarioMarketData repeatedScenarioMarketData = RepeatedScenarioMarketData.of(3, marketData);

            ImmutableScenarioMarketData immutableScenarioMarketData = ImmutableScenarioMarketData.builder(LocalDate.of(2011, 3, 8)).addTimeSeries(TEST_ID2, timeSeries2a).addTimeSeries(TEST_ID3, timeSeries3).addBox(TEST_ID2, MarketDataBox.ofScenarioValues(2.0, 2.1, 2.2)).addBox(TEST_ID3, MarketDataBox.ofScenarioValues(3.0, 3.1, 3.2)).build();

            ScenarioMarketData combinedData = immutableScenarioMarketData.combinedWith(repeatedScenarioMarketData);

            assertThat(combinedData.ScenarioCount).isEqualTo(3);
            assertThat(combinedData.getValue(TEST_ID1).getValue(0)).isEqualTo(1.1);
            assertThat(combinedData.getValue(TEST_ID1).getValue(2)).isEqualTo(1.1);
            assertThat(combinedData.getValue(TEST_ID1).getValue(3)).isEqualTo(1.1);
            assertThat(combinedData.getValue(TEST_ID2)).isEqualTo(MarketDataBox.ofScenarioValues(2.0, 2.1, 2.2));
            assertThat(combinedData.getValue(TEST_ID3)).isEqualTo(MarketDataBox.ofScenarioValues(3.0, 3.1, 3.2));
            assertThat(combinedData.getTimeSeries(TEST_ID1)).isEqualTo(timeSeries1);
            assertThat(combinedData.getTimeSeries(TEST_ID2)).isEqualTo(timeSeries2a);
            assertThat(combinedData.getTimeSeries(TEST_ID3)).isEqualTo(timeSeries3);
        }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            RepeatedScenarioMarketData test = RepeatedScenarioMarketData.of(2, BASE_DATA);

            coverImmutableBean(test);
            RepeatedScenarioMarketData test2 = RepeatedScenarioMarketData.of(1, baseData2());

            coverBeanEquals(test, test2);
        }
        public virtual void test_scenario_byIndex()
        {
            RepeatedScenarioMarketData test = RepeatedScenarioMarketData.of(2, BASE_DATA);

            assertSame(test.scenario(0), BASE_DATA);
            assertSame(test.scenario(1), BASE_DATA);
            assertThrows(() => test.scenario(-1), typeof(System.IndexOutOfRangeException));
            assertThrows(() => test.scenario(2), typeof(System.IndexOutOfRangeException));
        }
コード例 #5
0
 //-----------------------------------------------------------------------
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         RepeatedScenarioMarketData other = (RepeatedScenarioMarketData)obj;
         return((scenarioCount == other.scenarioCount) && JodaBeanUtils.equal(underlying, other.underlying));
     }
     return(false);
 }
        //-------------------------------------------------------------------------
        public virtual void test_of()
        {
            RepeatedScenarioMarketData test = RepeatedScenarioMarketData.of(2, BASE_DATA);

            assertEquals(test.ScenarioCount, 2);
            assertEquals(test.Underlying, BASE_DATA);
            assertEquals(test.ValuationDate, MarketDataBox.ofSingleValue(VAL_DATE));
            assertEquals(test.containsValue(ID1), true);
            assertEquals(test.containsValue(ID2), true);
            assertEquals(test.containsValue(ID3), false);
            assertEquals(test.getValue(ID1), MarketDataBox.ofSingleValue(VAL1));
            assertEquals(test.getValue(ID2), MarketDataBox.ofSingleValue(VAL2));
            assertThrows(() => test.getValue(ID3), typeof(MarketDataNotFoundException));
            assertEquals(test.findValue(ID1), MarketDataBox.ofSingleValue(VAL1));
            assertEquals(test.findValue(ID2), MarketDataBox.ofSingleValue(VAL2));
            assertEquals(test.findValue(ID3), null);
            assertEquals(test.Ids, ImmutableSet.of(ID1, ID2));
            assertEquals(test.findIds(ID1.MarketDataName), ImmutableSet.of(ID1));
            assertEquals(test.getTimeSeries(ID4), TIME_SERIES);
        }
        public virtual void serialization()
        {
            RepeatedScenarioMarketData test = RepeatedScenarioMarketData.of(2, BASE_DATA);

            assertSerialization(test);
        }