프로젝트

일반

사용자정보

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

markus / ConvertService / ServiceBase / Markus.Service.DataBase.Test / DataBaseConvertDoc.cs @ c1946e9c

이력 | 보기 | 이력해설 | 다운로드 (6.94 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
                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

    
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
                    break;
75
                }
76
            }
77
        }
78

    
79
        /// <summary>
80
        /// 완료
81
        /// </summary>
82
        [Test, Description("Select waitOrError msSQL 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 MS SQL Test")]
101
        public void SelectTop10ConvertDoc()
102
        {
103
            using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype))
104
            {
105
                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,"
106
                             + "RECONVERTER FROM CONVERTER_DOC where CREATE_DATETIME >= @CREATE_DATETIME order by CREATE_DATETIME";
107

    
108
                var parameter = new List<sqlParameter>();
109

    
110
                parameter.Add(new sqlParameter("@CREATE_DATETIME", DateTime.Now.AddDays(-10), System.Data.DbType.DateTime));
111

    
112
                var items = repository.GetAsync<Markus.Service.DataBase.Entities.ConvertDoc>(sql, parameter).GetAwaiter().GetResult();
113

    
114
                foreach (var item in items)
115
                {
116
                    Assert.Pass(item.ID);
117
                }
118
            }
119
        }
120

    
121

    
122
        /// <summary>
123
        /// 완료.
124
        /// </summary>
125
        [Test, Description("CONVERT_SELECT_CONVERTINGITEMS")]
126
        public void CONVERT_SELECT_CONVERTINGITEMS()
127
        {
128
            int TakeCount = 5;
129
            using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype))
130
            {
131
                var items = repository.GetConvertingItemAsync(TakeCount).GetAwaiter().GetResult();
132

    
133
                foreach (var item in items)
134
                {
135
                    Assert.Pass(item.ID);
136
                }
137
            }
138
        }
139

    
140
        /// <summary>
141
        /// 완료.
142
        /// </summary>
143
        [Test, Description("SetCleanUpItem PostgreSQL Test")]
144
        public void SelectSetCleanUpItem()
145
        {
146
            this.CreateConvertDoc();
147

    
148
            foreach (var item in newConvertDocIDs)
149
            {
150
                using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype))
151
                {
152
                    var items = repository.SetCleanUpItemAsync(item, 1).GetAwaiter().GetResult();
153

    
154
                    Assert.Pass(item);
155
                }
156
            }
157
        }
158

    
159

    
160
        /// <summary>
161
        /// 완료.
162
        /// </summary>
163
        [Test, Description("UpdateStatusAsync")]
164
        public void UpdateStatusAsync()
165
        {
166
            using (Markus.Service.DataBase.Repositories.ConvertDocRepository repository = new Repositories.ConvertDocRepository(ConnectionStr, dbtype))
167
            {
168
                var newConvertDocID = repository.CreateAsync(ProjectNo, docUri, "111111").GetAwaiter().GetResult();
169

    
170
                var convertDoc = repository.GetConvertDocSingleAsync(ProjectNo, ConvertID: newConvertDocID).GetAwaiter().GetResult();
171

    
172
                Console.WriteLine($"ID : {convertDoc.ID} PROJECT_NO:{convertDoc.PROJECT_NO} DOCUMENT_URL:{convertDoc.DOCUMENT_URL} DOCUMENT_ID:{convertDoc.DOCUMENT_ID}  ConvertPath:{convertDoc.ConvertPath}  ");
173

    
174
                var status = repository.UpdateStatusAsync("", convertDoc.ID , convertDoc.STATUS, convertDoc.TOTAL_PAGE, convertDoc.CURRENT_PAGE, "").GetAwaiter().GetResult();
175

    
176
                Assert.That(status, Is.EqualTo(1));
177

    
178
              
179
            }
180
        }
181

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