프로젝트

일반

사용자정보

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

markus / ConvertService / ServiceBase / Markus.Service.DataBase.Test / DataBaseConvertDocPG.cs @ 9e974b65

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

1
using Dapper;
2
using NUnit.Framework;
3
using System;
4
using System.Collections.Generic;
5

    
6
namespace Markus.Service.DataBase.Test
7
{
8
    /// <summary>
9
    /// PostgreSQL
10
    /// </summary>
11
    public class DataBaseConvertDocPG : TestBasePG
12
    {
13
        public List<string> newConvertDocIDs = new List<string>();
14
        /// <summary>
15
        /// 완료
16
        /// </summary>
17
        [Test, Description("Craete Convert Doc Postgresql Test")]
18
        public void CreateConvertDocAsync()
19
        {
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
                Assert.Pass(newConvertDocID);
27
                var newConvertDocID2 = repository.CreateAsync(ProjectNo, docUri, "A1111111").GetAwaiter().GetResult();
28

    
29
                newConvertDocIDs.Add(newConvertDocID2);
30
                Console.WriteLine($"new id : {newConvertDocID2}");
31
                Assert.Pass(newConvertDocID2);
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
                var newConvertDocID2 = repository.Create(ProjectNo, docUri, "A1111111").GetAwaiter().GetResult();
51

    
52
                newConvertDocIDs.Add(newConvertDocID2);
53
                Console.WriteLine($"new id : {newConvertDocID2}");
54
                Assert.Pass(newConvertDocID2);
55

    
56
            }
57
        }
58

    
59
        /// <summary>
60
        /// 완료
61
        /// </summary>
62
        [Test, Description("GetConvertDocSingle Test")]
63
        public void GetConvertDocSingle()
64
        {
65
            this.CreateConvertDoc();
66

    
67
            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
                    Assert.Pass(convertDoc.ID);
73
                    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

    
79
        /// <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
        [Test, Description("Select Top 10 Convert Doc PostgreSQL Test")]
101
        public void SelectTop10ConvertDoc()
102
        {
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
                             + "RECONVERTER FROM CONVERTER_DOC where CREATE_DATETIME >= @CREATE_DATETIME order by CREATE_DATETIME desc limit 10";
107
               
108
                var parameter = new List<sqlParameter>();
109
                parameter.Add(new sqlParameter("@CREATE_DATETIME", DateTime.Now.AddDays(-2), System.Data.DbType.DateTime));
110
  
111
               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

    
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

    
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
                var status = repository.UpdateStatusAsync("", convertDoc.ID, convertDoc.STATUS, convertDoc.TOTAL_PAGE, convertDoc.CURRENT_PAGE, "").GetAwaiter().GetResult();
174

    
175
                //Assert.That(status, Is.EqualTo(1));
176
            }
177
        }
178

    
179
    }
180
}
클립보드 이미지 추가 (최대 크기: 500 MB)