Ejemplo n.º 1
0
		public void OrdersExtract()
		{
			SqlServerStorage storage = new SqlServerStorage(typeof(OrdersVerticalBar));
			
			storage.ServerName = "NEON-64";
			storage.DatabaseName = "Northwind";

			storage.SelectSql = "SELECT * FROM Orders";
			storage.FillRecordCallback = new FillRecordHandler(FillRecordOrder);

			OrdersVerticalBar[] res = null;

			try
			{
				res = storage.ExtractRecords() as OrdersVerticalBar[];
			}
			catch(SqlException ex)
			{
				if (ex.Number == 208)
					Assert.Ignore("You dont have this tables in your SqlServer");

				if (ex.Number == 6)
					Assert.Ignore("SqlServer not found, skipping this test.");

				Assert.Ignore(ex.ToString());
			}

			Assert.AreEqual(830, res.Length);

			Assert.AreEqual("VINET", res[0].CustomerID);
			Assert.AreEqual("TOMSP", res[1].CustomerID);
			Assert.AreEqual("HANAR", res[2].CustomerID);
		}
Ejemplo n.º 2
0
		public void OrdersExtractToFile()
		{
			SqlServerStorage storage = new SqlServerStorage(typeof(OrdersVerticalBar));
			
			storage.ServerName = "NEON-64";
			storage.DatabaseName = "Northwind";

			storage.SelectSql = "SELECT * FROM Orders";
			storage.FillRecordCallback = new FillRecordHandler(FillRecordOrder);

			try
			{
				FileDataLink.EasyExtractToFile(storage, "tempord.txt");
			}
			catch(SqlException ex)
			{
				if (ex.Number == 208)
					Assert.Ignore("You dont have this tables in your SqlServer");

				if (ex.Number == 6)
					Assert.Ignore("SqlServer not found, skipping this test.");

				Assert.Ignore(ex.ToString());
			}


			FileDataLink link = new FileDataLink(storage);
			link.ExtractToFile("tempord.txt");

			OrdersVerticalBar[] res = CommonEngine.ReadFile(typeof(OrdersVerticalBar), "tempord.txt") as OrdersVerticalBar[];

			if (File.Exists("tempord.txt")) File.Delete("tempord.txt");

			Assert.AreEqual(830, res.Length);

			Assert.AreEqual("VINET", res[0].CustomerID);
			Assert.AreEqual("TOMSP", res[1].CustomerID);
			Assert.AreEqual("HANAR", res[2].CustomerID);
		}
Ejemplo n.º 3
0
        public void CustomersInsertEasy()
        {
            var storage = new SqlServerStorage(typeof (CustomersVerticalBar));

            storage.ServerName = "NEON-64";
            storage.DatabaseName = "Northwind";

            storage.InsertSqlCallback = new InsertSqlHandler(GetInsertSqlCust);

            try {
                FileDataLink.EasyInsertFromFile(storage, TestCommon.GetPath("Good", "CustomersVerticalBar.txt"));
            }
            catch (SqlException ex) {
                if (ex.Number == 208)
                    Assert.Ignore("You dont have this tables in your SqlServer");

                if (ex.Number == 6)
                    Assert.Ignore("SqlServer not found, skipping this test.");

                Assert.Ignore(ex.ToString());
            }
        }
Ejemplo n.º 4
0
		public void OrdersInsertBad()
		{
			SqlServerStorage storage = new SqlServerStorage(typeof(OrdersVerticalBar));
			
			storage.ServerName = "NEON-64";
			storage.DatabaseName = "Northwind";

			storage.InsertSqlCallback = new InsertSqlHandler(GetInsertSqlOrder);
			OrdersVerticalBar[] res = (OrdersVerticalBar[]) CommonEngine.ReadFile(typeof(OrdersVerticalBar), Common.TestPath(@"Good\OrdersVerticalBar.txt"));
			OrdersVerticalBar[] res2 = new OrdersVerticalBar[1];
			res2[0] = res[0];

			//storage.ExecuteInBatchSize
			//res2[0].OrderDate = new DateTime(1750, 10, 10);
			try
			{
				storage.InsertRecords(res2);
			}
			catch(SqlException ex)
			{
				if (ex.Number == 208)
					Assert.Ignore("You dont have this tables in your SqlServer");

				if (ex.Number == 6)
					Assert.Ignore("SqlServer not found, skipping this test.");

				Assert.Ignore(ex.ToString());
			}

		}
Ejemplo n.º 5
0
		public void CustomerInsert()
		{
			SqlServerStorage storage = new SqlServerStorage(typeof(CustomersVerticalBar));
			
			storage.ServerName = "NEON-64";
			storage.DatabaseName = "Northwind";

			storage.InsertSqlCallback = new InsertSqlHandler(GetInsertSqlCust);

			try
			{
				storage.InsertRecords(CommonEngine.ReadFile(typeof(CustomersVerticalBar), Common.TestPath(@"Good\CustomersVerticalBar.txt")));
			}
			catch(SqlException ex)
			{
				if (ex.Number == 208)
					Assert.Ignore("You dont have this tables in your SqlServer");

				if (ex.Number == 6)
					Assert.Ignore("SqlServer not found, skipping this test.");

				Assert.Ignore(ex.ToString());
			}


		}
Ejemplo n.º 6
0
		public void OrdersExtractBad5()
		{
			SqlServerStorage storage = new SqlServerStorage(typeof(OrdersVerticalBar), "WhereIsThisServer", "Northwind");
			
			storage.SelectSql = "SELECT TOP 100 * FROM Orders";

			storage.ExtractRecords();
		}
Ejemplo n.º 7
0
		public void OrdersExtractBad4()
		{
			SqlServerStorage storage = new SqlServerStorage(typeof(OrdersVerticalBar), "NEON-64", "SureThatThisDontExist");
			
			storage.SelectSql = "SELECT TOP 100 * FROM Orders";

			storage.ExtractRecords();
		}
Ejemplo n.º 8
0
		public void OrdersExtractBad3()
		{
			SqlServerStorage storage = new SqlServerStorage(typeof(OrdersVerticalBar), "NEON-64", "Northwind");
			
			storage.SelectSql = "SELECT TOP 100 * FROM Orders";

			try
			{
				storage.ExtractRecords();
			}
			catch(SqlException ex)
			{
				if (ex.Number == 208)
					Assert.Ignore("You dont have this tables in your SqlServer");

				if (ex.Number == 6)
					Assert.Ignore("SqlServer not found, skipping this test.");

				Assert.Ignore(ex.ToString());
			}
		}
Ejemplo n.º 9
0
		public void OrdersExtractBad2()
		{
			SqlServerStorage storage = new SqlServerStorage(typeof(OrdersVerticalBar));
			
			storage.SelectSql = "SELECT TOP 100 * FROM Orders";
			storage.FillRecordCallback = new FillRecordHandler(FillRecordOrder);

			storage.ExtractRecords();
		}
Ejemplo n.º 10
0
		public void OrdersExtractBad1()
		{
			SqlServerStorage storage = new SqlServerStorage(typeof(OrdersVerticalBar), "NEON-64", "Northwind");
			
			storage.FillRecordCallback = new FillRecordHandler(FillRecordOrder);
			storage.ExtractRecords();
		}
Ejemplo n.º 11
0
        public void OrdersExtractBad5()
        {
            var storage = new SqlServerStorage(typeof (OrdersVerticalBar), "WhereIsThisServer", "Northwind");

            storage.SelectSql = "SELECT TOP 100 * FROM Orders";

            Assert.Throws<SqlException>(()
                => storage.ExtractRecords());
        }
Ejemplo n.º 12
0
        public void OrdersExtractBad4()
        {
            var storage = new SqlServerStorage(typeof (OrdersVerticalBar), "NEON-64", "SureThatThisDontExist");

            storage.SelectSql = "SELECT TOP 100 * FROM Orders";


            Assert.Throws<SqlException>(()
                => storage.ExtractRecords());
        }
Ejemplo n.º 13
0
        public void OrdersExtractBad2()
        {
            var storage = new SqlServerStorage(typeof (OrdersVerticalBar));

            storage.SelectSql = "SELECT TOP 100 * FROM Orders";
            storage.FillRecordCallback = new FillRecordHandler(FillRecordOrder);

            Assert.Throws<BadUsageException>(()
                => storage.ExtractRecords());
        }
Ejemplo n.º 14
0
        public void OrdersExtractBad1()
        {
            var storage = new SqlServerStorage(typeof (OrdersVerticalBar), "NEON-64", "Northwind");

            storage.FillRecordCallback = new FillRecordHandler(FillRecordOrder);

            Assert.Throws<BadUsageException>(()
                => storage.ExtractRecords());
        }