public void Preface()
 {
     var item = new Schema();
     var data = Guid.NewGuid().ToString();
     item.Preface = data;
     Assert.AreEqual(data, item.Preface);
 }
 public void MaxLength()
 {
     var item = new Schema();
     var data = Guid.NewGuid().ToString();
     item.MaxLength = data;
     Assert.AreEqual(data, item.MaxLength);
 }
 public void IsPrimaryKey()
 {
     var item = new Schema();
     Assert.IsFalse(item.IsPrimaryKey);
     item.IsPrimaryKey = true;
     Assert.IsTrue(item.IsPrimaryKey);
 }
 public void DataType()
 {
     var item = new Schema();
     var data = Guid.NewGuid().ToString();
     item.DataType = data;
     Assert.AreEqual(data, item.DataType);
 }
 public void ParameterName()
 {
     var item = new Schema();
     var data = Guid.NewGuid().ToString();
     item.ParameterName = data;
     Assert.AreEqual(data, item.ParameterName);
 }
        public void BuildManifest()
        {
            var random = new Random();
            var defs = new List<Definition>();
            var schemas = new List<Schema>();
            var schema = new Schema()
            {
                Name = Guid.NewGuid().ToString(),
                Preface = Guid.NewGuid().ToString(),
            };
            var def = schema.Map<Definition>();
            defs.Add(def);

            var schemaCount = random.Next(15);
            for (var i = 0; i < schemaCount; i++)
            {
                var s = new Schema()
                {
                    Name = schema.Name,
                    Preface = schema.Preface,
                    DataType = Guid.NewGuid().ToString(),
                    ParameterName = Guid.NewGuid().ToString(),
                };
                schemas.Add(s);
            }
            var count = random.Next(15);
            for (var i = 0; i < count; i++)
            {
                var d = new Definition()
                {
                    Name = Guid.NewGuid().ToString(),
                    Preface = Guid.NewGuid().ToString(),
                };
                defs.Add(d);
            }

            var executor = Substitute.For<IExecutor>();
            var statements = Substitute.For<IStatements>();

            var dl = new SchemaReader(executor, statements);
            var manifest = dl.BuildManifest(defs, schemas);

            Assert.IsNotNull(manifest);
            Assert.AreEqual(count + 1, manifest.Count());
            var c = new DefinitionComparer();
            Assert.AreEqual(schemaCount, manifest.ElementAt(0).Variables.Count());
        }
        public void Minimize()
        {
            var schemas = new List<Schema>();
            var schema = new Schema()
            {
                Name = Guid.NewGuid().ToString(),
                Preface = Guid.NewGuid().ToString(),
            };

            schemas.AddRange(new[] { schema, schema, schema, schema });

            var executor = Substitute.For<IExecutor>();
            var statements = Substitute.For<IStatements>();
            var dl = new SchemaReader(executor, statements);
            var returned = dl.Minimize(schemas);

            Assert.IsNotNull(returned);
            Assert.AreEqual(1, returned.Count());
            var def = returned.FirstOrDefault();
            Assert.IsNotNull(def);
            Assert.AreEqual(schema.Name, def.Name);
            Assert.AreEqual(schema.Preface, def.Preface);
        }