Mercurial > pub > bltoolkit
comparison UnitTests/CS/JointureTests/AssociationTests.cs @ 0:f990fcb411a9
Копия текущей версии из github
author | cin |
---|---|
date | Thu, 27 Mar 2014 21:46:09 +0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f990fcb411a9 |
---|---|
1 using System.Collections.Generic; | |
2 using BLToolkit.Data; | |
3 using BLToolkit.Data.DataProvider; | |
4 using BLToolkit.DataAccess; | |
5 using BLToolkit.Mapping; | |
6 using NUnit.Framework; | |
7 | |
8 namespace UnitTests.CS.JointureTests | |
9 { | |
10 //[TestFixture] | |
11 internal class AssociationTests | |
12 { | |
13 [TestFixtureSetUp] | |
14 public void Setup() | |
15 { | |
16 DataProviderBase provider = new OdpDataProvider(); | |
17 DbManager.AddDataProvider(provider); | |
18 DbManager.AddConnectionString(provider.Name, | |
19 string.Format( | |
20 "data source={0};User Id={1};Password={2};Incr Pool Size=1;Max Pool Size=3; Connection Timeout=15; pooling=false", | |
21 "MUSICFR01.TEST", "scurutchet", "kisscool12")); | |
22 } | |
23 | |
24 //[Test] | |
25 public void SelectAllArtistsIgnoreLazyLoading() | |
26 { | |
27 using (var db = new MusicDB()) | |
28 { | |
29 var query2 = new FullSqlQuery(db, true); //loading is automatic | |
30 var artist2 = (Artist2) query2.SelectByKey(typeof (Artist2), 2643); | |
31 var titles2 = artist2.Titles; | |
32 | |
33 var query = new FullSqlQuery(db); // Dont ignore lazyloading | |
34 var artist = (Artist2) query.SelectByKey(typeof (Artist2), 2643); | |
35 var titles = artist.Titles; | |
36 Assert.AreEqual(titles2.Count, titles.Count); | |
37 } | |
38 } | |
39 | |
40 //[Test] | |
41 public void SelectAllArtistsLazyLoading() | |
42 { | |
43 // using (var db = new MusicDB()) | |
44 // { | |
45 // var dbCmd = db.SetCommand("SELECT ID_ARTIST FROM PITAFR01.Artist where date_creation > sysdate - 200"); | |
46 // | |
47 // dbCmd.MappingSchema = new FullMappingSchema(); | |
48 // | |
49 // var art = dbCmd.ExecuteList<Artist2>(); | |
50 // var titles = art[0].Titles; | |
51 // var query2 = new FullSqlQueryT<Artist2>(db); | |
52 // var artists = query2.SelectAll(); | |
53 // var artist2 = artists[0]; | |
54 // var titles2 = artist2.Titles; | |
55 // } | |
56 } | |
57 | |
58 //[Test] | |
59 public void SelectAllTitlesFull() | |
60 { | |
61 using (var db = new MusicDB()) | |
62 { | |
63 var query = new FullSqlQueryT<Title>(db); | |
64 var titles1 = query.SelectAll<List<Title>>(); | |
65 List<Title> titles2 = query.SelectAll(); | |
66 } | |
67 } | |
68 | |
69 //[Test] | |
70 public void SelectAllTitlesFull2() | |
71 { | |
72 using (var db = new MusicDB()) | |
73 { | |
74 var query2 = new FullSqlQuery(db); | |
75 var titles = query2.SelectAll<Title>(); | |
76 var title = (Title) query2.SelectByKey(typeof (Title), 137653); | |
77 } | |
78 } | |
79 | |
80 //[Test] | |
81 public void SelectArtistFullWithLazyLoadingTitles() | |
82 { | |
83 using (var db = new MusicDB()) | |
84 { | |
85 var query2 = new FullSqlQueryT<Artist2>(db); | |
86 var artist = query2.SelectByKey(2643); | |
87 var titles = artist.Titles; | |
88 } | |
89 } | |
90 | |
91 //[Test] | |
92 public void SelectTitleFull() | |
93 { | |
94 using (var db = new MusicDB()) | |
95 { | |
96 var query2 = new FullSqlQueryT<Title>(db); | |
97 var title = query2.SelectByKey(137653); | |
98 var titleName = title.Name; | |
99 } | |
100 } | |
101 } | |
102 } |