public void GetIndicatorByIdTest()
 {
     IndicatorDAO target = new IndicatorDAO(connnetion);
     int providerId = 1;
     int indicatorId = 1;
     Indicator expected = new Indicator
     {
         ID = 1,
         Name = "Densidade populacional (N.º/ km²) por Local de residência; Anual",
         NameAbbr = "Densidade populacional (N.º/ km²)",
         Provider = new Provider
         {
             ID = 1,
             Name = "Instituto Nacional de Estatística",
             NameAbbr = "INE",
             ServiceURL = "http://localhost:42136/INEStatisticsProvider.svc",
             URL = "http://www.ine.pt"
         },
         SourceID = "0000009",
         SubThemeID = 1,
         ThemeID = 1
     };
     Indicator actual;
     actual = target.GetIndicatorById(providerId, indicatorId);
     Assert.AreEqual(expected, actual);
 }
 public int AddIndicator(Indicator indicator)
 {
     using (IndicatorDAO.Connection = ConnectionSettings.CreateDBConnection())
     {
         return IndicatorDAO.AddIndicator(indicator);
     }
 }
Beispiel #3
0
 public int AddIndicator(Indicator indicator)
 {
     return DbTemplateHelper<int>.GetValueByProcedure(
         Connection,
         "config.insertindicator",
         new DbParameterHelper[]
         {
             new DbParameterHelper(DbType.String,    "p_name",           indicator.Name),
             new DbParameterHelper(DbType.String,    "p_nameAbbr",       indicator.NameAbbr),
             new DbParameterHelper(DbType.String,    "p_sourceid",       indicator.SourceID),
             new DbParameterHelper(DbType.Int32,     "p_themeid",        indicator.ThemeID),
             new DbParameterHelper(DbType.Int32,     "p_subthemeid",     indicator.SubThemeID),
             new DbParameterHelper(DbType.Int32,     "p_providerid",     indicator.Provider.ID)
         });
 }
Beispiel #4
0
        public static void addConfiguration(DbConnection conn, Indicator indicator, string lowestGeoLevel)
        {
            var configurationDAO = new ConfigurationDAO(conn);
            for (int geoLevel = int.Parse(lowestGeoLevel); geoLevel >= 2; --geoLevel)
            {
                GEOLevels level = (GEOLevels)geoLevel;

                Console.WriteLine("... Adding configuration: {0} ....", level.ToString());

                DataStore.Common.Model.Configuration config = new DataStore.Common.Model.Configuration
                {
                    GeoLevel = level.ToString(),
                    Shapefile = new Shapefile
                    {
                        ID = SHAPEFILE_IDS[level]
                    }
                };
                configurationDAO.AddConfiguration(indicator.ID, config);
            }
        }
Beispiel #5
0
        private static void addIndicators(DbConnection conn, Provider p, IEnumerable<ExtendedSubTheme> subthemes, INEService.Statistics ine)
        {
            Console.WriteLine(":::::::::: Adding indicatores :::::::::");

            var indicatorDAO = new IndicatorDAO(conn);

            foreach (var subtheme in subthemes)
            {
                INEService.IndicatorPlus indicators = ine.GetIndicatorsByTheme(GEOVERSION, subtheme.SourceThemeCode, LANGUAGE, 2, 1, 10000);
                foreach (var indicator in indicators.Indicators)
                {
                    Console.WriteLine("... Adding indicator: {0} ....", subtheme.NameAbbr);

                    Indicator convertedIndicator = new Indicator
                    {
                        Name = indicator.Designation,
                        NameAbbr = indicator.Abbreviation,
                        Provider = p,
                        SourceID = indicator.Code,
                        SubThemeID = subtheme.ID,
                        ThemeID = subtheme.ThemeID
                    };
                    convertedIndicator.ID = indicatorDAO.AddIndicator(convertedIndicator);

                    addConfiguration(conn, convertedIndicator, indicator.GeoLevelCode);
                }
            }
        }
        private static Mock<IIndicatorDAO> GetIndicatorDAOMock()
        {
            var indicator = new Indicator
            {
                ID = 1,
                Name = "foo",
                NameAbbr = "foo",
                Provider = new Provider
                {
                    ID = 1,
                    Name = "provider 1",
                    ServiceURL = "http://nowhere.com",
                    URL = "http://nowhere.com"
                },
                SourceID = "1"
            };

            var mockIndicatorDAO = new Mock<IIndicatorDAO>();
            mockIndicatorDAO.Setup(m => m.GetIndicatorById(It.IsAny<int>(), It.IsAny<int>())).Returns(indicator);

            return mockIndicatorDAO;
        }