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