public OuterTableTests() { var leftInfo = new TableInfo(ObjectName.Parse("tab1")); leftInfo.Columns.Add(new ColumnInfo("a", PrimitiveTypes.Integer())); leftInfo.Columns.Add(new ColumnInfo("b", PrimitiveTypes.Boolean())); var temp1 = new TemporaryTable(leftInfo); temp1.AddRow(new [] { SqlObject.Integer(23), SqlObject.Boolean(true) }); temp1.AddRow(new [] { SqlObject.Integer(54), SqlObject.Boolean(null) }); left = temp1; var rightInfo = new TableInfo(ObjectName.Parse("tab2")); rightInfo.Columns.Add(new ColumnInfo("a", PrimitiveTypes.Integer())); rightInfo.Columns.Add(new ColumnInfo("b", PrimitiveTypes.Boolean())); var temp2 = new TemporaryTable(rightInfo); temp2.AddRow(new [] { SqlObject.Integer(15), SqlObject.Boolean(true) }); temp2.AddRow(new [] { SqlObject.Integer(544), SqlObject.Boolean(false) }); right = temp2; }
public static void EnuemrateRows() { var tableInfo = new TableInfo(new ObjectName("table1")); tableInfo.Columns.Add(new ColumnInfo("a", PrimitiveTypes.Integer())); tableInfo.Columns.Add(new ColumnInfo("b", PrimitiveTypes.VarChar(22))); var table = new TemporaryTable(tableInfo); table.AddRow(new SqlObject[] { SqlObject.Integer(22), SqlObject.String(new SqlString("test")), }); table.AddRow(new [] { SqlObject.Integer(15002933), SqlObject.String(new SqlString("test2")), }); Assert.Equal(2, table.Count()); var row1 = table.ElementAt(0); var row2 = table.ElementAt(1); Assert.Equal(SqlObject.Integer(22), row1["a"]); Assert.Equal(SqlObject.String(new SqlString("test")), row1["b"]); Assert.Equal(SqlObject.Integer(15002933), row2["a"]); }
public FilterTableTests() { var leftInfo = new TableInfo(ObjectName.Parse("tab1")); leftInfo.Columns.Add(new ColumnInfo("a", PrimitiveTypes.Integer())); leftInfo.Columns.Add(new ColumnInfo("b", PrimitiveTypes.Boolean())); left = new TemporaryTable(leftInfo); left.AddRow(new[] { SqlObject.Integer(23), SqlObject.Boolean(true) }); left.AddRow(new[] { SqlObject.Integer(54), SqlObject.Boolean(null) }); left.BuildIndex(); }
public VirtualTableTests() { var leftInfo = new TableInfo(ObjectName.Parse("tab1")); leftInfo.Columns.Add(new ColumnInfo("a", PrimitiveTypes.Integer())); leftInfo.Columns.Add(new ColumnInfo("b", PrimitiveTypes.Boolean())); var temp = new TemporaryTable(leftInfo); temp.AddRow(new [] { SqlObject.Integer(23), SqlObject.Boolean(true) }); temp.AddRow(new [] { SqlObject.Integer(54), SqlObject.Boolean(null) }); left = temp; }
public FunctionTableTests() { var leftInfo = new TableInfo(ObjectName.Parse("tab1")); leftInfo.Columns.Add(new ColumnInfo("a", PrimitiveTypes.Integer())); leftInfo.Columns.Add(new ColumnInfo("b", PrimitiveTypes.Boolean())); left = new TemporaryTable(leftInfo); left.AddRow(new[] { SqlObject.Integer(23), SqlObject.Boolean(true) }); left.AddRow(new[] { SqlObject.Integer(54), SqlObject.Boolean(null) }); left.BuildIndex(); var scope = new ServiceContainer(); var mock = new Mock <IContext>(); mock.SetupGet(x => x.Scope) .Returns(scope); mock.Setup(x => x.Dispose()) .Callback(scope.Dispose); context = mock.Object; var group = new List <SqlObject> { SqlObject.Integer(33), SqlObject.Integer(22), SqlObject.Integer(1) }; var refResolver = new Mock <IReferenceResolver>(); refResolver.Setup(x => x.ResolveType(It.IsAny <ObjectName>())) .Returns <ObjectName>(name => PrimitiveTypes.Integer()); refResolver.Setup(x => x.ResolveReferenceAsync(It.IsAny <ObjectName>())) .Returns <ObjectName>(name => Task.FromResult(group[0])); var resolverMock = new Mock <IGroupResolver>(); resolverMock.SetupGet(x => x.Size) .Returns(group.Count); resolverMock.Setup(x => x.ResolveReferenceAsync(It.IsAny <ObjectName>(), It.IsAny <long>())) .Returns <ObjectName, long>((name, index) => Task.FromResult(group[(int)index])); resolverMock.Setup(x => x.GetResolver(It.IsAny <long>())) .Returns(refResolver.Object); // scope.AddMethodRegistry<SystemFunctionProvider>(); scope.RegisterInstance <IGroupResolver>(resolverMock.Object); }
public SubsetTableTests() { var leftInfo = new TableInfo(ObjectName.Parse("tab1")); leftInfo.Columns.Add(new ColumnInfo("a", PrimitiveTypes.Integer())); leftInfo.Columns.Add(new ColumnInfo("b", PrimitiveTypes.Boolean())); leftInfo.Columns.Add(new ColumnInfo("c", PrimitiveTypes.Double())); var temp = new TemporaryTable(leftInfo); temp.AddRow(new[] { SqlObject.Integer(23), SqlObject.Boolean(true), SqlObject.Double(5563.22) }); temp.AddRow(new[] { SqlObject.Integer(54), SqlObject.Boolean(null), SqlObject.Double(921.001) }); temp.AddRow(new[] { SqlObject.Integer(23), SqlObject.Boolean(true), SqlObject.Double(2010.221) }); left = temp; }
public CrossJoinedTableTests() { var leftInfo = new TableInfo(ObjectName.Parse("tab1")); leftInfo.Columns.Add(new ColumnInfo("a", PrimitiveTypes.Integer())); leftInfo.Columns.Add(new ColumnInfo("b", PrimitiveTypes.Boolean())); var left = new TemporaryTable(leftInfo); left.AddRow(new[] { SqlObject.Integer(23), SqlObject.Boolean(true) }); left.AddRow(new[] { SqlObject.Integer(54), SqlObject.Boolean(null) }); var rightInfo = new TableInfo(ObjectName.Parse("tab2")); rightInfo.Columns.Add(new ColumnInfo("a", PrimitiveTypes.Integer())); rightInfo.Columns.Add(new ColumnInfo("b", PrimitiveTypes.Boolean())); var right = new TemporaryTable(rightInfo); right.AddRow(new[] { SqlObject.Integer(15), SqlObject.Boolean(true) }); right.AddRow(new[] { SqlObject.Integer(544), SqlObject.Boolean(false) }); table = new CrossJoinedTable(left, right); }
public static async Task CreateAndAddRows() { var tableInfo = new TableInfo(new ObjectName("table1")); tableInfo.Columns.Add(new ColumnInfo("a", PrimitiveTypes.Integer())); tableInfo.Columns.Add(new ColumnInfo("b", PrimitiveTypes.VarChar(22))); var table = new TemporaryTable(tableInfo); table.AddRow(new SqlObject[] { SqlObject.Integer(22), SqlObject.String(new SqlString("test")), }); Assert.Equal(1, table.RowCount); var value1 = await table.GetValueAsync(0, 0); var value2 = await table.GetValueAsync(0, 1); Assert.Equal(SqlObject.Integer(22), value1); Assert.Equal(SqlObject.String(new SqlString("test")), value2); }