コード例 #1
0
        public async Task TwoFederatedDsOnSingleRemoteServiceTest()
        {
            FederationTestConfigurationProvider provider = new FederationTestConfigurationProvider();
            Dictionary <string, StaticValuesForRectDataHandler[]> federatedDsDict = new Dictionary <string, StaticValuesForRectDataHandler[]>();

            federatedDsDict["http://1/"] = new StaticValuesForRectDataHandler[] { new Static_25_45_Handler(), new Static_30_50_Handler() };
            federatedDsDict["http://2/"] = new StaticValuesForRectDataHandler[] { new Static_35_55_Handler() };
            FederatedDsTestingFetchEngine fetchEngine = new FederatedDsTestingFetchEngine(provider, federatedDsDict);

            FetchDomain fd = FetchDomain.CreatePoints(new double[] { 5.0, 5.0, 5.0, 5.0 }, new double[] { 37.0, 42.0, 47.0, 52.0 }, new TimeRegion());

            FetchRequest request = new FetchRequest("a", fd, new string[] { "25_45", "30_50" });

            FetchResponseWithProvenance result = await fetchEngine.PerformRequestAsync(request);

            Assert.AreEqual(-60.0, result.Values.GetValue(0));
            Assert.AreEqual(60.0, result.Uncertainty.GetValue(0));
            Assert.AreEqual((ushort)1, result.Provenance.GetValue(0));

            Assert.AreEqual(-60.0, result.Values.GetValue(1));
            Assert.AreEqual(60.0, result.Uncertainty.GetValue(1));
            Assert.AreEqual((ushort)1, result.Provenance.GetValue(1));

            Assert.AreEqual(-70.0, result.Values.GetValue(2));
            Assert.AreEqual(70.0, result.Uncertainty.GetValue(2));
            Assert.AreEqual((ushort)2, result.Provenance.GetValue(2));

            Assert.AreEqual(-160.0, result.Values.GetValue(3));
            Assert.AreEqual(160.0, result.Uncertainty.GetValue(3));
            Assert.AreEqual((ushort)1, result.Provenance.GetValue(3));
        }
コード例 #2
0
        public async Task FetchingSingleDataSourceTest()
        {
            FederationTestConfigurationProvider provider = new FederationTestConfigurationProvider();
            Dictionary <string, StaticValuesForRectDataHandler[]> federatedDsDict = new Dictionary <string, StaticValuesForRectDataHandler[]>();

            federatedDsDict["http://1/"] = new StaticValuesForRectDataHandler[] { new Static_25_45_Handler(), new Static_30_50_Handler() };
            federatedDsDict["http://2/"] = new StaticValuesForRectDataHandler[] { new Static_35_55_Handler() };
            FederatedDsTestingFetchEngine fetchEngine = new FederatedDsTestingFetchEngine(provider, federatedDsDict);

            FetchDomain fd = FetchDomain.CreatePoints(new double[] { 5.0 }, new double[] { 37.0 }, new TimeRegion());

            FetchRequest request = new FetchRequest("a", fd, new string[] { "20_40" }); //local

            FetchResponseWithProvenance result = await fetchEngine.PerformRequestAsync(request);

            Assert.AreEqual(-50.0, result.Values.GetValue(0));
            Assert.AreEqual(50.0, result.Uncertainty.GetValue(0));
            Assert.AreEqual((ushort)0, result.Provenance.GetValue(0));


            request = new FetchRequest("a", fd, new string[] { "35_55" }); //federated

            result = await fetchEngine.PerformRequestAsync(request);

            Assert.AreEqual(-80.0, result.Values.GetValue(0));
            Assert.AreEqual(80.0, result.Uncertainty.GetValue(0));
            Assert.AreEqual((ushort)3, result.Provenance.GetValue(0));
        }
コード例 #3
0
        public async Task FederatedFetchingNanHandlingTest()
        {
            FederationTestConfigurationProvider provider = new FederationTestConfigurationProvider();
            Dictionary <string, StaticValuesForRectDataHandler[]> federatedDsDict = new Dictionary <string, StaticValuesForRectDataHandler[]>();

            federatedDsDict["http://1/"] = new StaticValuesForRectDataHandler[] { new Static_25_45_Handler(), new StaticNanYielding_30_50_Handler() };
            federatedDsDict["http://2/"] = new StaticValuesForRectDataHandler[] { new Static_35_55_Handler() };
            FederatedDsTestingFetchEngine fetchEngine = new FederatedDsTestingFetchEngine(provider, federatedDsDict);

            FetchDomain fd = FetchDomain.CreatePoints(new double[] { 5.0, 5.0, 5.0, 5.0 }, new double[] { 37.0, 42.0, 47.0, 52.0 }, new TimeRegion());

            FetchRequest request = new FetchRequest("a", fd);

            FetchResponseWithProvenance result = await fetchEngine.PerformRequestAsync(request);

            Assert.AreEqual(-50.0, result.Values.GetValue(0));
            Assert.AreEqual(50.0, result.Uncertainty.GetValue(0));
            Assert.AreEqual((ushort)0, result.Provenance.GetValue(0));

            Assert.AreEqual(-60.0, result.Values.GetValue(1)); //serve
            Assert.AreEqual(60.0, result.Uncertainty.GetValue(1));
            Assert.AreEqual((ushort)1, result.Provenance.GetValue(1));

            Assert.AreEqual(-80.0, result.Values.GetValue(2)); //here instead of StaticNanYielding_30_50_Handler, Static_35_55_Handler must provide results
            Assert.AreEqual(80.0, result.Uncertainty.GetValue(2));
            Assert.AreEqual((ushort)3, result.Provenance.GetValue(2));

            Assert.AreEqual(-80.0, result.Values.GetValue(3));
            Assert.AreEqual(80.0, result.Uncertainty.GetValue(3));
            Assert.AreEqual((ushort)3, result.Provenance.GetValue(3));
        }
コード例 #4
0
        public async Task FetchingUnregisteredDataSourceTest()
        {
            FederationTestConfigurationProvider provider = new FederationTestConfigurationProvider();
            Dictionary <string, StaticValuesForRectDataHandler[]> federatedDsDict = new Dictionary <string, StaticValuesForRectDataHandler[]>();

            federatedDsDict["http://1/"] = new StaticValuesForRectDataHandler[] { new Static_25_45_Handler(), new Static_30_50_Handler() };
            federatedDsDict["http://2/"] = new StaticValuesForRectDataHandler[] { new Static_35_55_Handler() };
            FederatedDsTestingFetchEngine fetchEngine = new FederatedDsTestingFetchEngine(provider, federatedDsDict);

            FetchDomain fd = FetchDomain.CreatePoints(new double[] { 5.0 }, new double[] { 37.0 }, new TimeRegion());

            FetchRequest request = new FetchRequest("a", fd, new string[] { "20_40_unregistered" });

            await fetchEngine.PerformRequestAsync(request);
        }