Ejemplo n.º 1
0
        public void GeneralTest()
        {
            DbStructureGateway g = DbStructureGateway.Instance;

            g.CreateTable(typeof(NewsItem));
            Assert.IsTrue(g.IsValid(typeof(NewsItem)), g.LastError);
            Assert.IsFalse(g.IsValid(typeof(NewsItem2)));


            DbTableCheckResult result = new DbTableCheckResult(DbAccessor.Instance);

            result.Build(typeof(NewsItem2));

            Assert.AreEqual(2, result.FieldsToCreate.Count);
            Assert.AreEqual(1, result.FieldsToUpdate.Count);


            g.DropTable(typeof(NewsItem));
            g.CreateTable(typeof(NewsItem2));
            Assert.IsTrue(g.IsValid(typeof(NewsItem2)));
            Assert.IsFalse(g.IsValid(typeof(NewsItem)));


            result = new DbTableCheckResult(DbAccessor.Instance);
            result.Build(typeof(NewsItem2));

            Assert.AreEqual(0, result.FieldsToCreate.Count);
            Assert.AreEqual(0, result.FieldsToUpdate.Count);
        }
Ejemplo n.º 2
0
        public void SetConnectionString(string connectionString)
        {
            Accessor         = DbAccessor.Create(Provider, connectionString);
            StructureGateway = new DbStructureGateway(Accessor);

            if (!Accessor.CanConnect)
            {
                throw new NdbException(string.Format(
                                           "Can't connect to \"{0}\" using {1} provider", connectionString, Provider));
            }
        }
Ejemplo n.º 3
0
        public void SetUp()
        {
            DbStructureGateway sgateway = DbStructureGateway.Instance;

            sgateway.DropTables(typeof(User).Assembly);
            sgateway.CreateTables(typeof(User).Assembly);

            TestData data = new TestData(sgateway.Accessor);
            long     user = data.CreateUser();

            generator = new DbCodeGenerator(sgateway)
            {
                Namespace = "ITCreatings.Ndb.GeneratedObjects"
            };
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Exports the specified types.
        /// </summary>
        /// <param name="types">The types.</param>
        /// <param name="ExportWithClean">if set to <c>true</c> than all existsing data will be removed first.</param>
        public void Export(Type[] types, bool ExportWithClean)
        {
            string     methodName = ExportWithClean ? "ExportWithClean" : "Export";
            MethodInfo method     = GetType().GetMethod(methodName, new Type[] {});

            DbStructureGateway structureGateway = new DbStructureGateway(Source);

            foreach (Type type in types)
            {
                string tableName = DbAttributesManager.GetTableName(type);

                if (structureGateway.IsTableExists(tableName))
                {
                    method.MakeGenericMethod(type).Invoke(this, null);
                }
            }
        }
Ejemplo n.º 5
0
 public DbTestFixture(DbAccessor accessor)
 {
     sgateway = new DbStructureGateway(accessor);
     gateway  = new DbGateway(accessor);
 }
Ejemplo n.º 6
0
 internal DbStructureGatewayTests(DbAccessor accessor)
 {
     gateway = new DbStructureGateway(accessor);
 }