프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / ConvertService / ServiceBase / Markus.Service.DataBase.Test / DataBaseConvertDocPG.cs @ 30d84e1a

이력 | 보기 | 이력해설 | 다운로드 (6.95 KB)

1 731c84b8 taeseongkim
using Dapper;
2
using NUnit.Framework;
3
using System;
4
using System.Collections.Generic;
5
6
namespace Markus.Service.DataBase.Test
7
{
8 bede677a GeunHo Song
    /// <summary>
9
    /// PostgreSQL
10
    /// </summary>
11 f6c94121 taeseongkim
    public class DataBaseConvertDocPG : TestBasePG
12 731c84b8 taeseongkim
    {
13
        public List<string> newConvertDocIDs = new List<string>();
14 bede677a GeunHo Song
        /// <summary>
15
        /// 완료
16
        /// </summary>
17
        [Test, Description("Craete Convert Doc Postgresql Test")]
18
        public void CreateConvertDocAsync()
19 f6c94121 taeseongkim
        {
20
            using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype))
21
            {
22
                var newConvertDocID = repository.CreateAsync(ProjectNo, docUri, "111111").GetAwaiter().GetResult();
23
24
                newConvertDocIDs.Add(newConvertDocID);
25
                Console.WriteLine($"new id : {newConvertDocID}");
26 c1946e9c GeunHo Song
              
27 f6c94121 taeseongkim
                var newConvertDocID2 = repository.CreateAsync(ProjectNo, docUri, "A1111111").GetAwaiter().GetResult();
28
29
                newConvertDocIDs.Add(newConvertDocID2);
30
                Console.WriteLine($"new id : {newConvertDocID2}");
31 9e974b65 GeunHo Song
                Assert.Pass(newConvertDocID2);
32 f6c94121 taeseongkim
            }
33
34
        }
35
36
37 bede677a GeunHo Song
        /// <summary>
38 9e974b65 GeunHo Song
            /// 완료
39 bede677a GeunHo Song
        /// </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 c1946e9c GeunHo Song
                
50 bede677a GeunHo Song
                var newConvertDocID2 = repository.Create(ProjectNo, docUri, "A1111111").GetAwaiter().GetResult();
51
52
                newConvertDocIDs.Add(newConvertDocID2);
53
                Console.WriteLine($"new id : {newConvertDocID2}");
54 9e974b65 GeunHo Song
                Assert.Pass(newConvertDocID2);
55
56 bede677a GeunHo Song
            }
57
        }
58
59
        /// <summary>
60
        /// 완료
61
        /// </summary>
62 f6c94121 taeseongkim
        [Test, Description("GetConvertDocSingle Test")]
63 0fce3dac taeseongkim
        public void GetConvertDocSingle()
64 f6c94121 taeseongkim
        {
65 bede677a GeunHo Song
            this.CreateConvertDoc();
66
67 f6c94121 taeseongkim
            using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype))
68
            {
69
                foreach (var convertDocID in newConvertDocIDs)
70
                {
71
                    var convertDoc = repository.GetConvertDocSingleAsync(ProjectNo, ConvertID: convertDocID).GetAwaiter().GetResult();
72 9e974b65 GeunHo Song
                    Assert.Pass(convertDoc.ID);
73 f6c94121 taeseongkim
                    Console.WriteLine($"ID : {convertDoc.ID} PROJECT_NO:{convertDoc.PROJECT_NO} DOCUMENT_URL:{convertDoc.DOCUMENT_URL} DOCUMENT_ID:{convertDoc.DOCUMENT_ID}  ConvertPath:{convertDoc.ConvertPath}  ");
74
                }
75
76
            }
77
        }
78 731c84b8 taeseongkim
79 bede677a GeunHo Song
        /// <summary>
80
        /// 완료
81
        /// </summary>
82
        [Test, Description("Select waitOrError PostgreSQL Test")]
83
        public void SelectWaitOrError()
84
        {
85
            using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype))
86
            {
87
                var items = repository.GetWaitorErrorAsync(2).GetAwaiter().GetResult();
88
89
                foreach (var item in items)
90
                {
91
                    Assert.Pass(item.ID);
92
                }
93
            }
94
        }
95
96
97
        /// <summary>
98
        /// 완료
99
        /// </summary>
100 52b947bb taeseongkim
        [Test, Description("Select Top 10 Convert Doc PostgreSQL Test")]
101
        public void SelectTop10ConvertDoc()
102 731c84b8 taeseongkim
        {
103
            using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype))
104
            {
105
                string sql = @"SELECT ID, PROJECT_NO, DOCUMENT_URL, DOCUMENT_ID, CREATE_DATETIME, STATUS, TOTAL_PAGE, CURRENT_PAGE, EXCEPTION, END_DATETIME, START_DATETIME, SERVICE_ID,"
106 bede677a GeunHo Song
                             + "RECONVERTER FROM CONVERTER_DOC where CREATE_DATETIME >= @CREATE_DATETIME order by CREATE_DATETIME desc limit 10";
107 731c84b8 taeseongkim
               
108
                var parameter = new List<sqlParameter>();
109 bede677a GeunHo Song
                parameter.Add(new sqlParameter("@CREATE_DATETIME", DateTime.Now.AddDays(-2), System.Data.DbType.DateTime));
110 f6c94121 taeseongkim
  
111 731c84b8 taeseongkim
               var items = repository.GetAsync<Markus.Service.DataBase.Entities.ConvertDoc>(sql, parameter).GetAwaiter().GetResult();
112
113
                foreach(var item in items)
114
                {
115
                    Assert.Pass(item.ID);
116
                }
117
            }
118
        }
119 0fce3dac taeseongkim
120 bede677a GeunHo Song
        /// <summary>
121
        /// 완료
122
        /// </summary>
123
        [Test, Description("CONVERT_SELECT_CONVERTINGITEMS")]
124
        public void CONVERT_SELECT_CONVERTINGITEMS()
125 0fce3dac taeseongkim
        {
126 bede677a GeunHo Song
            int TakeCount = 5;
127 0fce3dac taeseongkim
            using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype))
128
            {
129 bede677a GeunHo Song
                var items = repository.GetConvertingItemAsync(TakeCount).GetAwaiter().GetResult();
130 0fce3dac taeseongkim
131
                foreach (var item in items)
132
                {
133
                    Assert.Pass(item.ID);
134
                }
135
            }
136
        }
137
138 bede677a GeunHo Song
        /// <summary>
139
        /// 완료.
140
        /// </summary>
141 0fce3dac taeseongkim
        [Test, Description("SetCleanUpItem PostgreSQL Test")]
142
        public void SelectSetCleanUpItem()
143
        {
144 bede677a GeunHo Song
            this.CreateConvertDoc();
145
146 0fce3dac taeseongkim
            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 bede677a GeunHo Song
157
158
159
        /// <summary>
160
        /// 완료.
161
        /// </summary>
162
        [Test, Description("UpdateStatusAsync")]
163
        public void UpdateStatusAsync()
164
        {
165
            using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype))
166
            {
167
                var newConvertDocID = repository.CreateAsync(ProjectNo, docUri, "111111").GetAwaiter().GetResult();
168
169
                var convertDoc = repository.GetConvertDocSingleAsync(ProjectNo, ConvertID: newConvertDocID).GetAwaiter().GetResult();
170
171
                Console.WriteLine($"ID : {convertDoc.ID} PROJECT_NO:{convertDoc.PROJECT_NO} DOCUMENT_URL:{convertDoc.DOCUMENT_URL} DOCUMENT_ID:{convertDoc.DOCUMENT_ID}  ConvertPath:{convertDoc.ConvertPath}  ");
172
173 9e974b65 GeunHo Song
                var status = repository.UpdateStatusAsync("", convertDoc.ID, convertDoc.STATUS, convertDoc.TOTAL_PAGE, convertDoc.CURRENT_PAGE, "").GetAwaiter().GetResult();
174 bede677a GeunHo Song
175 9e974b65 GeunHo Song
                //Assert.That(status, Is.EqualTo(1));
176 bede677a GeunHo Song
            }
177
        }
178
179 731c84b8 taeseongkim
    }
180
}
클립보드 이미지 추가 (최대 크기: 500 MB)