Ejemplo n.º 1
0
    public void Transforms_a_full_dataset()
    {
        var old = new Dictionary <int, IList <string> >
        {
            { 1, new List <string> {
                  "A", "E", "I", "O", "U", "L", "N", "R", "S", "T"
              } },
            { 2, new List <string> {
                  "D", "G"
              } },
            { 3, new List <string> {
                  "B", "C", "M", "P"
              } },
            { 4, new List <string> {
                  "F", "H", "V", "W", "Y"
              } },
            { 5, new List <string> {
                  "K"
              } },
            { 8, new List <string> {
                  "J", "X"
              } },
            { 10, new List <string> {
                  "Q", "Z"
              } },
        };
        var expected = new Dictionary <string, int>
        {
            { "a", 1 }, { "b", 3 }, { "c", 3 }, { "d", 2 }, { "e", 1 }, { "f", 4 }, { "g", 2 }, { "h", 4 }, { "i", 1 },
            { "j", 8 }, { "k", 5 }, { "l", 1 }, { "m", 3 }, { "n", 1 }, { "o", 1 }, { "p", 3 }, { "q", 10 }, { "r", 1 },
            { "s", 1 }, { "t", 1 }, { "u", 1 }, { "v", 4 }, { "w", 4 }, { "x", 8 }, { "y", 4 }, { "z", 10 }
        };

        Assert.Equal(expected, ETL.Transform(old));
    }
Ejemplo n.º 2
0
        /// <summary>
        /// Инициализация хранилища
        /// </summary>
        static void init()
        {
            //события
            DataSourceEvents dses = repository.CreateOrLoadMetaObject(MetaObjectType.DataSourceEvents, "DataSourceEvents") as DataSourceEvents;

            repository.Save(dses);
            //ETL
            ETL etl = repository.CreateOrLoadMetaObject(MetaObjectType.ETL, "etl1") as ETL;

            etl.AssemblyPath = Directory.GetCurrentDirectory() + "\\ETL.exe";
            etl.AssemblyArgs = connectionString;
            repository.Save(etl);
            //ETLs
            ETLs etls = repository.CreateOrLoadMetaObject(MetaObjectType.ETLs, "ETLs") as ETLs;

            etls.AddETL(etl);
            repository.Save(etls);
            //источник данных
            DataSource ds = repository.CreateOrLoadMetaObject(MetaObjectType.DataSource, "ds1") as DataSource;

            ds.DataSourceName = "Росстат. Население.";
            ds.DataSourceType = "type";
            ds.Url            = "url";
            ds.SetETL(etl);
            repository.Save(ds);
            //создаем расписание и задание
            ReglamentMetaObject rmo =
                repository.CreateOrLoadMetaObject(MetaObjectType.Reglament, "Reglament") as ReglamentMetaObject;
            ReglamentElementMetaObject remo =
                repository.CreateOrLoadMetaObject(MetaObjectType.ReglamentElement, "ReglamentElement" + Guid.NewGuid().ToString()) as ReglamentElementMetaObject;

            rmo.AddReglamentElement(remo);
            remo.Enabled = true;
            remo.ReglamentElementType = "ExecETL";
            remo.NextRunTime          = DateTime.Parse("18:37 17.6.2012");
            remo.Period = TimeSpan.FromMinutes(5);
            remo.SetDataSource(ds);

            repository.Save(remo);
            repository.Save(rmo);

            //задание проверки источника
            remo         = repository.CreateOrLoadMetaObject(MetaObjectType.ReglamentElement, "ReglamentElement" + Guid.NewGuid().ToString()) as ReglamentElementMetaObject;
            remo.Enabled = true;
            remo.ReglamentElementType = "CheckDS";
            remo.NextRunTime          = DateTime.Parse("00:59 19.6.2012");
            remo.Period = TimeSpan.FromMinutes(3);
            remo.SetDataSource(ds);
            repository.Save(remo);

            rmo.AddReglamentElement(remo);
            repository.Save(rmo);
        }
Ejemplo n.º 3
0
    public void Transforms_one_value()
    {
        var old = new Dictionary <int, IList <string> > {
            { 1, new List <string> {
                  "A"
              } }
        };
        var expected = new Dictionary <string, int> {
            { "a", 1 }
        };

        Assert.Equal(expected, ETL.Transform(old));
    }
Ejemplo n.º 4
0
    public void Transforms_multiple_values()
    {
        var old = new Dictionary <int, IList <string> > {
            { 1, new List <string> {
                  "A", "E", "I", "O", "U"
              } }
        };
        var expected = new Dictionary <string, int> {
            { "a", 1 }, { "e", 1 }, { "i", 1 }, { "o", 1 }, { "u", 1 }
        };

        Assert.Equal(expected, ETL.Transform(old));
    }
Ejemplo n.º 5
0
    public void Transforms_multiple_count_Element()
    {
        var old = new Dictionary <int, IList <string> > {
            { 1, new List <string> {
                  "A", "E", "I", "O", "U"
              } }
        };
        var expected = new Dictionary <string, int> {
            { "a", 1 }, { "e", 1 }, { "i", 1 }, { "o", 1 }, { "u", 1 }
        };

        Assert.That(ETL.Transform(old), Is.EqualTo(expected));
    }
Ejemplo n.º 6
0
    public void Transforms_multiple_keys()
    {
        var old = new Dictionary <int, IList <string> > {
            { 1, new List <string> {
                  "A", "E"
              } }, { 2, new List <string> {
                         "D", "G"
                     } }
        };
        var expected = new Dictionary <string, int> {
            { "a", 1 }, { "e", 1 }, { "d", 2 }, { "g", 2 }
        };

        Assert.Equal(expected, ETL.Transform(old));
    }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            // Add any code here to debug the Exercism.csharp classes

            var old = new Dictionary <int, IList <string> > {
                { 1, new List <string> {
                      "A", "E", "I", "O", "U"
                  } }
            };
            var expected = new Dictionary <string, int> {
                { "a", 1 }, { "e", 1 }, { "i", 1 }, { "o", 1 }, { "u", 1 }
            };

            ETL.Transform(old);
        }
Ejemplo n.º 8
0
    public void Handles_null_or_empty_values()
    {
        var old = new Dictionary <int, IList <string> > {
            { 1, new List <string> {
                  "A", ""
              } },
            { 2, new List <string> {
                  "D", null
              } },
            { 3, null }
        };
        var expected = new Dictionary <string, int> {
            { "a", 1 }, { "d", 2 }
        };

        Assert.That(ETL.Transform(old), Is.EqualTo(expected));
    }
Ejemplo n.º 9
0
    public void Handles_null_input()
    {
        var expected = new Dictionary <string, int>();

        Assert.That(ETL.Transform(null), Is.EqualTo(expected));
    }
Ejemplo n.º 10
0
 public void SetETL(ETL etl)
 {
     this.ETL_Id = (int)etl.Id;
 }
Ejemplo n.º 11
0
        //Методы
        public ETL GetETL()
        {
            ETL etl = _repository.LoadMetaObject(ETL_Id) as ETL;

            return(etl);
        }
Ejemplo n.º 12
0
 public void Init()
 {
     ETL = new ETL();
 }