Ejemplo n.º 1
0
        public void TransformToIntOnlyAliasWasnotAppliedAndOnlyOneKey()
        {
            Schemator schemator = new Schemator(new List <DataSourceSchemaItem>()
            {
                new DataSourceSchemaItem()
                {
                    //Alias = "MOMO",
                    ColumnName = "Col1",
                    Type       = ValueType.Int
                }
            });
            var sourceContext = new SourceContext();

            sourceContext.Source["Col1"] = "1";
            schemator.Schema(sourceContext);
            Assert.AreEqual(1, sourceContext.Source["Col1"]);
            Assert.AreEqual(1, sourceContext.Source.Keys.Count);
        }
Ejemplo n.º 2
0
        public void TransformCases(object from, ValueType type, object result)
        {
            Schemator schemator = new Schemator(new List <DataSourceSchemaItem>()
            {
                new DataSourceSchemaItem()
                {
                    Alias      = "MOMO",
                    ColumnName = "Col1",
                    Type       = type
                }
            });
            var sourceContext = new SourceContext();

            sourceContext.Source["Col1"] = from;
            schemator.Schema(sourceContext);
            Assert.AreEqual(result, sourceContext.Source["MOMO"]);
            Assert.AreEqual(1, sourceContext.Source.Keys.Count);
        }
Ejemplo n.º 3
0
        public void TransformToIntIsRequired()
        {
            Schemator schemator = new Schemator(new List <DataSourceSchemaItem>()
            {
                new DataSourceSchemaItem()
                {
                    Alias      = "MOMO",
                    ColumnName = "Col1",
                    Type       = ValueType.Int,
                    IsRequired = true
                }
            });
            var sourceContext = new SourceContext();

            sourceContext.Source["Col1"] = null;
            schemator.Schema(sourceContext);
            Assert.IsTrue(sourceContext.SourceCellErrors["Col1"][0].Message.ToLower().Contains("missed"));
        }