markus / ConvertService / ServiceBase / Markus.Service.DataBase.Test / DataBaseConvertDoc.cs @ 9e974b65
이력 | 보기 | 이력해설 | 다운로드 (7.02 KB)
1 |
|
---|---|
2 |
using NUnit.Framework; |
3 |
using NUnit.Framework.Interfaces; |
4 |
using System; |
5 |
using System.Collections.Generic; |
6 |
|
7 |
namespace Markus.Service.DataBase.Test |
8 |
{ |
9 |
public class DataBaseConvertDoc : TestBaseMSSQL |
10 |
{ |
11 |
public List<string> newConvertDocIDs = new List<string>(); |
12 |
|
13 |
/// <summary> |
14 |
/// 완료 |
15 |
/// </summary> |
16 |
[Test, Description("Craete Convert Doc MSSQL Test")] |
17 |
public void CreateConvertDocAsync() |
18 |
{ |
19 |
using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype)) |
20 |
{ |
21 |
var newConvertDocID = repository.CreateAsync(ProjectNo, docUri, "111111").GetAwaiter().GetResult(); |
22 |
|
23 |
newConvertDocIDs.Add(newConvertDocID); |
24 |
Console.WriteLine($"new id : {newConvertDocID}"); |
25 |
Assert.Pass(newConvertDocID); |
26 |
var newConvertDocID2 = repository.CreateAsync(ProjectNo, docUri, "A1111111").GetAwaiter().GetResult(); |
27 |
|
28 |
newConvertDocIDs.Add(newConvertDocID2); |
29 |
Console.WriteLine($"new id : {newConvertDocID2}"); |
30 |
Assert.Pass(newConvertDocID2); |
31 |
} |
32 |
|
33 |
|
34 |
} |
35 |
|
36 |
|
37 |
/// <summary> |
38 |
/// 완료 |
39 |
/// </summary> |
40 |
[Test, Description("Craete Convert Doc MSSQL Test")] |
41 |
public void CreateConvertDoc() |
42 |
{ |
43 |
using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype)) |
44 |
{ |
45 |
var newConvertDocID = repository.Create(ProjectNo, docUri, "111111").GetAwaiter().GetResult(); |
46 |
|
47 |
newConvertDocIDs.Add(newConvertDocID); |
48 |
Console.WriteLine($"new id : {newConvertDocID}"); |
49 |
Assert.Pass(newConvertDocID); |
50 |
|
51 |
var newConvertDocID2 = repository.Create(ProjectNo, docUri, "A1111111").GetAwaiter().GetResult(); |
52 |
|
53 |
newConvertDocIDs.Add(newConvertDocID2); |
54 |
Console.WriteLine($"new id : {newConvertDocID2}"); |
55 |
Assert.Pass(newConvertDocID2); |
56 |
} |
57 |
} |
58 |
|
59 |
|
60 |
/// <summary> |
61 |
/// 완료 |
62 |
/// </summary> |
63 |
[Test, Description("GetConvertDocSingle Test")] |
64 |
public void GetConvertDocSingle() |
65 |
{ |
66 |
this.CreateConvertDoc(); |
67 |
|
68 |
using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype)) |
69 |
{ |
70 |
foreach (var convertDocID in newConvertDocIDs) |
71 |
{ |
72 |
var convertDoc = repository.GetConvertDocSingleAsync(ProjectNo, ConvertID: convertDocID).GetAwaiter().GetResult(); |
73 |
Assert.Pass(convertDoc.ID); |
74 |
Console.WriteLine($"ID : {convertDoc.ID} PROJECT_NO:{convertDoc.PROJECT_NO} DOCUMENT_URL:{convertDoc.DOCUMENT_URL} DOCUMENT_ID:{convertDoc.DOCUMENT_ID} ConvertPath:{convertDoc.ConvertPath} "); |
75 |
break; |
76 |
} |
77 |
} |
78 |
} |
79 |
|
80 |
/// <summary> |
81 |
/// 완료 |
82 |
/// </summary> |
83 |
[Test, Description("Select waitOrError msSQL Test")] |
84 |
public void SelectWaitOrError() |
85 |
{ |
86 |
using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype)) |
87 |
{ |
88 |
var items = repository.GetWaitorErrorAsync(2).GetAwaiter().GetResult(); |
89 |
|
90 |
foreach (var item in items) |
91 |
{ |
92 |
Assert.Pass(item.ID); |
93 |
} |
94 |
} |
95 |
} |
96 |
|
97 |
|
98 |
/// <summary> |
99 |
/// 완료. |
100 |
/// </summary> |
101 |
[Test, Description("Select Top 10 Convert Doc MS SQL Test")] |
102 |
public void SelectTop10ConvertDoc() |
103 |
{ |
104 |
using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype)) |
105 |
{ |
106 |
string sql = @"SELECT TOP(10) ID, PROJECT_NO, DOCUMENT_URL, DOCUMENT_ID, CREATE_DATETIME, STATUS, TOTAL_PAGE, CURRENT_PAGE, EXCEPTION, END_DATETIME, START_DATETIME, SERVICE_ID," |
107 |
+ "RECONVERTER FROM CONVERTER_DOC where CREATE_DATETIME >= @CREATE_DATETIME order by CREATE_DATETIME"; |
108 |
|
109 |
var parameter = new List<sqlParameter>(); |
110 |
|
111 |
parameter.Add(new sqlParameter("@CREATE_DATETIME", DateTime.Now.AddDays(-10), System.Data.DbType.DateTime)); |
112 |
|
113 |
var items = repository.GetAsync<Markus.Service.DataBase.Entities.ConvertDoc>(sql, parameter).GetAwaiter().GetResult(); |
114 |
|
115 |
foreach (var item in items) |
116 |
{ |
117 |
Assert.Pass(item.ID); |
118 |
} |
119 |
} |
120 |
} |
121 |
|
122 |
|
123 |
/// <summary> |
124 |
/// 완료. |
125 |
/// </summary> |
126 |
[Test, Description("CONVERT_SELECT_CONVERTINGITEMS")] |
127 |
public void CONVERT_SELECT_CONVERTINGITEMS() |
128 |
{ |
129 |
int TakeCount = 5; |
130 |
using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype)) |
131 |
{ |
132 |
var items = repository.GetConvertingItemAsync(TakeCount).GetAwaiter().GetResult(); |
133 |
|
134 |
foreach (var item in items) |
135 |
{ |
136 |
Assert.Pass(item.ID); |
137 |
} |
138 |
} |
139 |
} |
140 |
|
141 |
/// <summary> |
142 |
/// 완료. |
143 |
/// </summary> |
144 |
[Test, Description("SetCleanUpItem PostgreSQL Test")] |
145 |
public void SelectSetCleanUpItem() |
146 |
{ |
147 |
this.CreateConvertDoc(); |
148 |
|
149 |
foreach (var item in newConvertDocIDs) |
150 |
{ |
151 |
using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype)) |
152 |
{ |
153 |
var items = repository.SetCleanUpItemAsync(item, 1).GetAwaiter().GetResult(); |
154 |
|
155 |
Assert.Pass(item); |
156 |
} |
157 |
} |
158 |
} |
159 |
|
160 |
|
161 |
/// <summary> |
162 |
/// 완료. |
163 |
/// </summary> |
164 |
[Test, Description("UpdateStatusAsync")] |
165 |
public void UpdateStatusAsync() |
166 |
{ |
167 |
using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype)) |
168 |
{ |
169 |
var newConvertDocID = repository.CreateAsync(ProjectNo, docUri, "111111").GetAwaiter().GetResult(); |
170 |
|
171 |
var convertDoc = repository.GetConvertDocSingleAsync(ProjectNo, ConvertID: newConvertDocID).GetAwaiter().GetResult(); |
172 |
|
173 |
Console.WriteLine($"ID : {convertDoc.ID} PROJECT_NO:{convertDoc.PROJECT_NO} DOCUMENT_URL:{convertDoc.DOCUMENT_URL} DOCUMENT_ID:{convertDoc.DOCUMENT_ID} ConvertPath:{convertDoc.ConvertPath} "); |
174 |
|
175 |
var status = repository.UpdateStatusAsync("", convertDoc.ID , convertDoc.STATUS, convertDoc.TOTAL_PAGE, convertDoc.CURRENT_PAGE, "").GetAwaiter().GetResult(); |
176 |
|
177 |
Assert.That(status, Is.EqualTo(1)); |
178 |
|
179 |
|
180 |
} |
181 |
} |
182 |
|
183 |
} |
184 |
} |