示例#1
0
        public void VariableTest()
        {
            db.TruncateTables();

            db.AddDataSource(
                "WorldClim 1.4",
                "A set of global climate layers (climate grids) with a spatial resolution of a square kilometer",
                "The database is documented in this article: Hijmans, R.J., S.E. Cameron, J.L. Parra, P.G. Jones and A. Jarvis, 2005. Very high resolution interpolated climate surfaces for global land areas. International Journal of Climatology 25: 1965-1978.", "Microsoft.Research.Science.FetchClimate2.DataSources.CRUProcessor, NCEPReanalysisDataSource",
                "msds:az?name=CRU_CL_2_0&DefaultEndpointsProtocol=http&AccountName=fetch&AccountKey=1Y0EOrnCX6ULY8c3iMHg9rrul2BWbPHKsHUceZ7SSh+ShM/q9K0ml49gQm+PE7G7i7zCvrpuT",
                null, null);
            db.AddVariable("MyVariable", "MyDescription", "MyUnits");
            db.AddVariable("MyVariable2", "MyDescription2", "MyUnits2");

            db.AddDataSource(
                "NCEP/NCAR Reanalysis 1 (regular grid)",
                "The NCEP/NCAR Reanalysis 1 project is using a state-of-the-art analysis/forecast system to perform data assimilation using past data from 1948 to the present",
                "NCEP Reanalysis data provided by the NOAA/OAR/ESRL PSD, Boulder, Colorado, USA, from their Web site at http://www.esrl.noaa.gov/psd/",
                "Microsoft.Research.Science.FetchClimate2.DataSources.NCEPReanalysisRegularGridDataSource, NCEPReanalysisDataSource",
                "msds:az?name=ReanalysisRegular&DefaultEndpointsProtocol=http&AccountName=fetch&AccountKey=1Y0EOrnCX6ULY8c3iMHg9rrul2BWbPHKsHUceZ7SSh+ShM/q9K0ml49gQm+PE7G7i7zCvrpuT",
                null, null);

            //STEP 1

            DateTime TIME_BEFORE_INSERTING = DateTime.UtcNow;

            Thread.Sleep(time);
            db.SetMapping("NCEP/NCAR Reanalysis 1 (regular grid)", "MyVariable", "TestDataSourceVariable", true, true);
            DateTime TIME_MIDDLE_INSERTING = DateTime.UtcNow;

            Thread.Sleep(time);
            db.SetMapping("WorldClim 1.4", "MyVariable", "TestDataSourceVariable", true, true);
            Thread.Sleep(time);
            db.SetMapping("WorldClim 1.4", "MyVariable2", "TestDataSourceVariable2", true, true);
            Thread.Sleep(time);
            db.SetMapping("WorldClim 1.4", "MyVariable", "TestDataSourceVariable", true, false);
            Thread.Sleep(time);
            var Variables = db.GetVariablesForDataSource(DateTime.UtcNow, "WorldClim 1.4").ToArray();

            Assert.AreEqual(1, Variables.Length);
            Assert.AreEqual("MyVariable2", Variables[0].DisplayName);
            Assert.AreEqual("MyDescription2", Variables[0].Description);
            Assert.AreEqual("MyUnits2", Variables[0].Units);

            //STEP 2

            //var EnvVariables = db.GetEnvVariables(TIME_MIDDLE_INSERTING).ToArray();
            //Assert.AreEqual(1, EnvVariables.Length);

            var EnvVariables = db.GetEnvVariables(/*DateTime.Now*/).ToArray();

            Assert.AreEqual(2, EnvVariables.Length);

            //STEP 3

            var DataSources = db.GetDataSourcesForVariable(DateTime.UtcNow, "MyVariable").ToArray();

            Assert.AreEqual(1, DataSources.Length);

            //STEP 4

            var Mappings = db.GetMapping(TIME_BEFORE_INSERTING, "NCEP/NCAR Reanalysis 1 (regular grid)").ToArray();

            Assert.AreEqual(0, Mappings.Length);

            Mappings = db.GetMapping(DateTime.UtcNow, "NCEP/NCAR Reanalysis 1 (regular grid)").ToArray();
            Assert.AreEqual(1, Mappings.Length);
            db.TruncateTables();
        }