예제 #1
0
        /// <summary>
        /// Tests building a tree of requirements using market data functions.
        /// </summary>
        public virtual void buildDependencyTree()
        {
            MarketDataNode expected = rootNode(observableNode(new TestIdA(this, "1")), valueNode(new TestIdB(this, "2"), valueNode(new TestIdB(this, "4"), observableNode(new TestIdA(this, "5"))), timeSeriesNode(new TestIdA(this, "3"))), timeSeriesNode(new TestIdA(this, "6")));

            // The requirements for the data directly used by the calculations
            MarketDataRequirements requirements = MarketDataRequirements.builder().addValues(new TestIdA(this, "1"), new TestIdB(this, "2")).addTimeSeries(new TestIdA(this, "6")).build();

            // Requirements for each item in the tree - used to initialize the functions
            MarketDataRequirements id2Reqs = MarketDataRequirements.builder().addTimeSeries(new TestIdA(this, "3")).addValues(new TestIdB(this, "4")).build();

            MarketDataRequirements id4Reqs = MarketDataRequirements.builder().addValues(new TestIdA(this, "5")).build();

            ImmutableMap <TestIdB, MarketDataRequirements> reqsMap = ImmutableMap.of(new TestIdB(this, "2"), id2Reqs, new TestIdB(this, "4"), id4Reqs);

            TestMarketDataFunctionA builderA = new TestMarketDataFunctionA();
            TestMarketDataFunctionB builderB = new TestMarketDataFunctionB(reqsMap);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.google.common.collect.ImmutableMap<Class, MarketDataFunction<?, ?>> functions = com.google.common.collect.ImmutableMap.of(TestIdA.class, builderA, TestIdB.class, builderB);
            ImmutableMap <Type, MarketDataFunction <object, ?> > functions = ImmutableMap.of(typeof(TestIdA), builderA, typeof(TestIdB), builderB);

            MarketDataNode root = MarketDataNode.buildDependencyTree(requirements, BuiltScenarioMarketData.empty(), MarketDataConfig.empty(), functions);

            assertThat(root).isEqualTo(expected);
        }
예제 #2
0
        /// <summary>
        /// Tests that supplied data is in a leaf node and the functions aren't asked for dependencies for supplied data.
        /// </summary>
        public virtual void noDependenciesForSuppliedData()
        {
            MarketDataNode expected1 = rootNode(valueNode(new TestIdB(this, "1"), observableNode(new TestIdA(this, "2"))), valueNode(new TestIdB(this, "3"), valueNode(new TestIdB(this, "4"))));

            MarketDataRequirements requirements = MarketDataRequirements.builder().addValues(new TestIdB(this, "1"), new TestIdB(this, "3")).build();

            MarketDataRequirements id1Reqs = MarketDataRequirements.builder().addValues(new TestIdA(this, "2")).build();

            MarketDataRequirements id3Reqs = MarketDataRequirements.builder().addValues(new TestIdB(this, "4")).build();

            ImmutableMap <TestIdB, MarketDataRequirements> reqsMap = ImmutableMap.of(new TestIdB(this, "1"), id1Reqs, new TestIdB(this, "3"), id3Reqs);

            TestMarketDataFunctionB builder = new TestMarketDataFunctionB(reqsMap);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.google.common.collect.ImmutableMap<Class, MarketDataFunction<?, ?>> functions = com.google.common.collect.ImmutableMap.of(TestIdB.class, builder);
            ImmutableMap <Type, MarketDataFunction <object, ?> > functions = ImmutableMap.of(typeof(TestIdB), builder);

            MarketDataNode root1 = MarketDataNode.buildDependencyTree(requirements, BuiltScenarioMarketData.empty(), MarketDataConfig.empty(), functions);

            assertThat(root1).isEqualTo(expected1);

            BuiltScenarioMarketData suppliedData = BuiltScenarioMarketData.builder(date(2011, 3, 8)).addValue(new TestIdB(this, "1"), new TestMarketDataB()).addValue(new TestIdB(this, "3"), new TestMarketDataB()).build();

            MarketDataNode root2 = MarketDataNode.buildDependencyTree(requirements, suppliedData, MarketDataConfig.empty(), functions);

            MarketDataNode expected2 = rootNode(valueNode(new TestIdB(this, "1")), valueNode(new TestIdB(this, "3")));

            assertThat(root2).isEqualTo(expected2);
        }
예제 #3
0
        /// <summary>
        /// Test a node with no children is added when there is no market data function for an ID.
        /// </summary>
        public virtual void noMarketDataBuilder()
        {
            MarketDataNode expected = rootNode(valueNode(new TestIdC("1")), valueNode(new TestIdB(this, "2"), valueNode(new TestIdC("3"))));

            MarketDataRequirements requirements = MarketDataRequirements.builder().addValues(new TestIdC("1"), new TestIdB(this, "2")).build();

            MarketDataRequirements id2Reqs = MarketDataRequirements.builder().addValues(new TestIdC("3")).build();

            TestMarketDataFunctionB builder = new TestMarketDataFunctionB(ImmutableMap.of(new TestIdB(this, "2"), id2Reqs));
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.google.common.collect.ImmutableMap<Class, MarketDataFunction<?, ?>> functions = com.google.common.collect.ImmutableMap.of(TestIdB.class, builder);
            ImmutableMap <Type, MarketDataFunction <object, ?> > functions = ImmutableMap.of(typeof(TestIdB), builder);
            // Build the tree without providing a market data function to handle TestId3
            MarketDataNode root = MarketDataNode.buildDependencyTree(requirements, BuiltScenarioMarketData.empty(), MarketDataConfig.empty(), functions);

            assertThat(root).isEqualTo(expected);
        }