FluentData.IntegrationTests/Providers/DB2/DB2ProviderTests.cs

(开头部分) 11KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System.Collections.Generic;
using FluentData.Providers.MySql;
using FluentData._Helpers;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace FluentData.Providers.DB2
{
	[TestClass]
	public class DB2ProviderTests : IDbProviderTests
	{
		public DB2ProviderTests()
		{
			var found = Context().Sql("select count(*) from sysibm.systables where name ='CATEGORY';").QueryValue<int>();
			if (found > 0)
			    Context().Sql("drop table ADMIN.CATEGORY;").Execute();

			found = Context().Sql("select count(*) from sysibm.systables where name ='PRODUCT';").QueryValue<int>();
			if (found > 0)
			    Context().Sql("drop table ADMIN.PRODUCT;").Execute();

			found = Context().Sql("select count(*) from sysibm.sysroutines where routinename ='PRODUCTUPDATE';").QueryValue<int>();
			if (found > 0)
				Context().Sql("drop procedure ADMIN.PRODUCTUPDATE;").Execute();

			Context().Sql(@"CREATE TABLE Category(
								CategoryId INTEGER NOT NULL,
								Name VARCHAR(50),
								PRIMARY KEY(CategoryId));

								CREATE TABLE Product(
								ProductId INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
								Name VARCHAR(50),
								CategoryId INTEGER NOT NULL,
								Primary Key(ProductId));

							insert into Category(CategoryId, Name) values(1, 'Books');
							insert into Category(CategoryId, Name) values(2, 'Movies');

							insert into Product(Name, CategoryId) values('The Warren Buffet Way', 1);
							insert into Product(Name, CategoryId) values('Bill Gates Bio', 1);
							insert into Product(Name, CategoryId) values('James Bond - Goldeneye', 2);
							insert into Product(Name, CategoryId) values('The Bourne Identity', 2);

							create procedure ProductUpdate(in ParamProductId integer, ParamName varchar(50))
								update Product set Name = ParamName where ProductId = ParamProductId;
							").Execute();
		}

		protected IDbContext Context()
		{
			return new DbContext().ConnectionString(TestHelper.GetConnectionStringValue("DB2"), DbProviderTypes.DB2);
		}

		[TestMethod]
		public void Query_many_dynamic()
		{
			var products = Context().Sql("select * from Product").Query();

			Assert.IsTrue(products.Count > 0);
		}
后面还有 351 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。