PageRenderTime 14ms CodeModel.GetById 8ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/Rhino.Etl.Tests/BaseUserToPeopleTest.cs

http://github.com/ayende/rhino-etl
C# | 78 lines | 74 code | 4 blank | 0 comment | 0 complexity | 3f0ac0406ed7dd6e737747c4e172adf0 MD5 | raw file
 1using Rhino.Etl.Core.Infrastructure;
 2
 3namespace Rhino.Etl.Tests
 4{
 5    using System.Collections.Generic;
 6    using System.Data;
 7    using Aggregation;
 8    using Xunit;
 9
10    public class BaseUserToPeopleTest : BaseDslTest
11    {
12        public BaseUserToPeopleTest()
13        {
14            Use.Transaction("test", delegate(IDbCommand cmd)
15            {
16                cmd.CommandText =
17                    @"
18if object_id('User2Role') is not null
19    drop table User2Role;
20if object_id('Roles') is not null
21    drop table Roles;
22if object_id('Users') is not null
23    drop table Users;
24
25create table Users ( id int identity primary key, name nvarchar(255) not null, email nvarchar(255) not null, roles nvarchar(255), testMsg nvarchar(255) );
26create table Roles( id int identity, name nvarchar(255) );
27
28
29create table User2Role( userid int, roleid int);
30
31insert into users (name,email) values('ayende rahien', 'ayende@example.org')
32insert into users (name,email) values('foo bar', 'fubar@example.org')
33insert into users (name,email) values('nice naughty', 'santa@example.org')
34insert into users (name,email) values('gold silver', 'dwarf@example.org')
35
36
37insert into roles values('admin')
38insert into roles values('janitor')
39insert into roles values('employee')
40insert into roles values('customer')
41
42insert into User2Role values(1,1)
43insert into User2Role values(1,2)
44insert into User2Role values(1,3)
45insert into User2Role values(1,4)
46insert into User2Role values(2,2)
47insert into User2Role values(4,2)
48insert into User2Role values(4,3)
49
50if object_id('People') is not null
51    drop table People;
52create table People ( id int identity, userid int not null, firstname nvarchar(255) not null, lastname nvarchar(255) not null, email nvarchar(255) not null);
53";
54                cmd.ExecuteNonQuery();
55            });
56        }
57
58        protected static void AssertNames(IList<string[]> names)
59        {
60            Assert.Equal("ayende", names[0][0]);
61            Assert.Equal("rahien", names[0][1]);
62            Assert.Equal("foo", names[1][0]);
63            Assert.Equal("bar", names[1][1]);
64            Assert.Equal("nice", names[2][0]);
65            Assert.Equal("naughty", names[2][1]);
66            Assert.Equal("gold", names[3][0]);
67            Assert.Equal("silver", names[3][1]);
68        }
69
70        protected static void AssertFullNames(IList<string> names)
71        {
72            Assert.Equal("ayende rahien", names[0]);
73            Assert.Equal("foo bar", names[1]);
74            Assert.Equal("nice naughty", names[2]);
75            Assert.Equal("gold silver", names[3]);
76        }
77    }
78}