Commit dd96c9a25f41f0e30ef3e7831bf3ffa171f0f1fb
1 parent
26b7ada8
WSA-53
"Break up nunit test files into more moduler self contained tests" Deleted. This file was too big. Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7647 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
0 additions
and
500 deletions
ktwebservice/nunit/document.cs deleted
| 1 | -using NUnit.Framework; | |
| 2 | -using System; | |
| 3 | -using System.IO; | |
| 4 | - | |
| 5 | -namespace MonoTests.KnowledgeTree | |
| 6 | -{ | |
| 7 | - [TestFixture] | |
| 8 | - public class DocumentTest | |
| 9 | - { | |
| 10 | - | |
| 11 | - private String _session; | |
| 12 | - private KnowledgeTreeService _kt; | |
| 13 | - | |
| 14 | - private String FILE1_NAME = "/tmp/kt_unit_test1.txt"; | |
| 15 | - private String FILE2_NAME = "/tmp/kt_unit_test2.txt"; | |
| 16 | - private String FILE3_NAME = "/tmp/kt_unit_test3.txt"; | |
| 17 | - private String FILE1_CONTENT = "hello world"; | |
| 18 | - private String FILE2_CONTENT = "this is a test"; | |
| 19 | - private String FILE3_CONTENT = "we do like unit tests!"; | |
| 20 | - private String NEW_DOCUMENT_TYPE = "Default"; | |
| 21 | - private String NEW_OWNER = "admin"; | |
| 22 | - private String NEW_DOCUMENT_FILENAME = "kt_unit_test-1.txt"; | |
| 23 | - private String NEW_DOCUMENT_TITLE = "unit test 1"; | |
| 24 | - private String NEW_WORKFLOW = "leave"; | |
| 25 | - private String NEW_WORKFLOW_STATE = "approved"; | |
| 26 | - private String NEW_WORKFLOW_START = "approved"; | |
| 27 | - private String NEW_TRANSITION = "approve"; | |
| 28 | - | |
| 29 | - private int[] _doc_id; | |
| 30 | - private int _folder_id; | |
| 31 | - private bool _skip; | |
| 32 | - | |
| 33 | - | |
| 34 | - [SetUp] | |
| 35 | - public void SetUp() | |
| 36 | - { | |
| 37 | - this._skip = true; | |
| 38 | - if (this._skip) return; | |
| 39 | - this._kt = new KnowledgeTreeService(); | |
| 40 | - kt_response response = this._kt.login("admin","admin","127.0.0.1"); | |
| 41 | - this._session = response.message; | |
| 42 | - | |
| 43 | - writeFile(FILE1_NAME, FILE1_CONTENT); | |
| 44 | - writeFile(FILE2_NAME, FILE2_CONTENT); | |
| 45 | - writeFile(FILE3_NAME, FILE3_CONTENT); | |
| 46 | - | |
| 47 | - this._folder_id = 1; | |
| 48 | - | |
| 49 | - } | |
| 50 | - | |
| 51 | - [TearDown] | |
| 52 | - public void TearDown() | |
| 53 | - { | |
| 54 | - if (this._skip) return; | |
| 55 | - this._kt.logout(this._session); | |
| 56 | - | |
| 57 | - | |
| 58 | - deleteFile(FILE1_NAME); | |
| 59 | - deleteFile(FILE2_NAME); | |
| 60 | - deleteFile(FILE3_NAME); | |
| 61 | - | |
| 62 | - for(int i=0;i<3;i++) | |
| 63 | - { | |
| 64 | - this._kt.delete_document(this._session, this._doc_id[i], "TearDown"); | |
| 65 | - } | |
| 66 | - | |
| 67 | - } | |
| 68 | - | |
| 69 | - private void validateDocumentDetail(kt_document_detail response1) | |
| 70 | - { | |
| 71 | - | |
| 72 | - Assert.AreEqual(0, response1.status_code); | |
| 73 | - Assert.AreEqual("kt unit test1", response1.title); | |
| 74 | - Assert.AreEqual("Default", response1.document_type); | |
| 75 | - Assert.AreEqual("0.1", response1.version); | |
| 76 | - Assert.AreEqual("kt_unit_test1.txt", response1.filename); | |
| 77 | - | |
| 78 | - Assert.IsFalse(response1.created_date == null); | |
| 79 | - Assert.IsFalse(response1.created_date == ""); | |
| 80 | - | |
| 81 | - Assert.AreEqual("admin", response1.created_by); | |
| 82 | - | |
| 83 | - Assert.IsTrue(response1.updated_date == null); | |
| 84 | - Assert.IsTrue(response1.updated_date == ""); | |
| 85 | - | |
| 86 | - Assert.IsTrue(response1.updated_by == null); | |
| 87 | - Assert.IsTrue(response1.updated_by == ""); | |
| 88 | - | |
| 89 | - Assert.IsTrue(response1.document_id > 0); | |
| 90 | - | |
| 91 | - Assert.AreEqual(this._folder_id, response1.folder_id); | |
| 92 | - | |
| 93 | - Assert.IsTrue(response1.workflow == null); | |
| 94 | - Assert.IsTrue(response1.workflow == ""); | |
| 95 | - | |
| 96 | - Assert.IsTrue(response1.workflow_state == null); | |
| 97 | - Assert.IsTrue(response1.workflow_state == ""); | |
| 98 | - | |
| 99 | - Assert.AreEqual("Root Folder/kt_unit_test1.txt", response1.full_path); | |
| 100 | - } | |
| 101 | - | |
| 102 | - [Test] | |
| 103 | - public void AddDocument() | |
| 104 | - { | |
| 105 | - if (this._skip) return; | |
| 106 | - this._doc_id = new int[3]; | |
| 107 | - | |
| 108 | - // document a | |
| 109 | - | |
| 110 | - kt_document_detail response1 = this._kt.add_base64_document(this._session, this._folder_id, "kt unit test1", "kt_unit_test1.txt", "Default", ConvertFileToBase64Encoding(FILE1_NAME)); | |
| 111 | - | |
| 112 | - | |
| 113 | - validateDocumentDetail(response1); | |
| 114 | - | |
| 115 | - // document b | |
| 116 | - | |
| 117 | - kt_document_detail response2 = this._kt.add_base64_document(this._session, this._folder_id, "kt unit test2", "kt_unit_test2.txt", "Default", ConvertFileToBase64Encoding(FILE2_NAME)); | |
| 118 | - Assert.AreEqual(0, response2.status_code); | |
| 119 | - Assert.IsTrue(response2.document_id > 0); | |
| 120 | - Assert.AreEqual("Root Folder/kt_unit_test2.txt", response2.full_path); | |
| 121 | - | |
| 122 | - // document c | |
| 123 | - kt_document_detail response3 = this._kt.add_base64_document(this._session, this._folder_id, "kt unit test3", "kt_unit_test3.txt", "Default", ConvertFileToBase64Encoding(FILE3_NAME)); | |
| 124 | - Assert.AreEqual(0, response3.status_code); | |
| 125 | - Assert.IsTrue(response3.document_id > 0); | |
| 126 | - Assert.AreEqual("Root Folder/kt_unit_test3.txt", response3.full_path); | |
| 127 | - | |
| 128 | - this._doc_id[0] = response1.document_id; | |
| 129 | - this._doc_id[1] = response2.document_id; | |
| 130 | - this._doc_id[2] = response3.document_id; | |
| 131 | - | |
| 132 | - | |
| 133 | - | |
| 134 | - } | |
| 135 | - | |
| 136 | - [Test] | |
| 137 | - public void GetDocumentDetail() | |
| 138 | - { | |
| 139 | - if (this._skip) return; | |
| 140 | - // test referencing a non existant object - should fail | |
| 141 | - kt_document_detail response = this._kt.get_document_detail(this._session, -1); | |
| 142 | - Assert.IsFalse(response.status_code == 0); | |
| 143 | - | |
| 144 | - // get document we added based on id | |
| 145 | - response = this._kt.get_document_detail(this._session, this._doc_id[0]); | |
| 146 | - validateDocumentDetail(response); | |
| 147 | - Assert.AreEqual(this._doc_id[0], response.document_id); | |
| 148 | - | |
| 149 | - // get document based on title | |
| 150 | - response = this._kt.get_document_detail_by_name(this._session, "Root Folder/kt unit test1", "T"); | |
| 151 | - validateDocumentDetail(response); | |
| 152 | - Assert.AreEqual(this._doc_id[0], response.document_id); | |
| 153 | - | |
| 154 | - // get document based on file | |
| 155 | - response = this._kt.get_document_detail_by_name(this._session, "Root Folder/kt_unit_test1.txt", "F"); | |
| 156 | - validateDocumentDetail(response); | |
| 157 | - Assert.AreEqual(this._doc_id[0], response.document_id); | |
| 158 | - | |
| 159 | - // test accessing file by filename that does not exist - should fail | |
| 160 | - response = this._kt.get_document_detail_by_name(this._session, "Root Folder/kt_unit_test1.ssssdasdasd", "F"); | |
| 161 | - Assert.IsFalse(response.status_code == 0); | |
| 162 | - } | |
| 163 | - | |
| 164 | - | |
| 165 | - [Test] | |
| 166 | - public void LinkDocuments() | |
| 167 | - { | |
| 168 | - if (this._skip) return; | |
| 169 | - // get document link types | |
| 170 | - kt_linked_document_response linkresp = this._kt.get_document_links(this._session, this._doc_id[0]); | |
| 171 | - Assert.AreEqual(0, linkresp.status_code); | |
| 172 | - | |
| 173 | - | |
| 174 | - // TODO: length test | |
| 175 | - //Assert.IsTrue(linkresp.links == 0); | |
| 176 | - | |
| 177 | - // link a to b | |
| 178 | - kt_response response = this._kt.link_documents(this._session, this._doc_id[0], this._doc_id[1], "Reference"); | |
| 179 | - Assert.AreEqual(0, response.status_code); | |
| 180 | - | |
| 181 | - // link a to c | |
| 182 | - response = this._kt.link_documents(this._session, this._doc_id[0], this._doc_id[1], "Reference"); | |
| 183 | - Assert.AreEqual(0, response.status_code); | |
| 184 | - | |
| 185 | - // get list on a | |
| 186 | - linkresp = this._kt.get_document_links(this._session, this._doc_id[0]); | |
| 187 | - Assert.AreEqual(0, linkresp.status_code); | |
| 188 | - // TODO: length test | |
| 189 | - //Assert.IsTrue(linkresp.links.length == 2); | |
| 190 | - | |
| 191 | - Assert.AreEqual("kt unit test2", linkresp.links[0].title); | |
| 192 | - Assert.IsTrue(linkresp.links[0].document_id == this._doc_id[0]); | |
| 193 | - Assert.AreEqual("kt unit test3", linkresp.links[1].title); | |
| 194 | - Assert.IsTrue(linkresp.links[1].document_id == this._doc_id[1]); | |
| 195 | - | |
| 196 | - // unlink c from a | |
| 197 | - response = this._kt.unlink_documents(this._session, this._doc_id[0], this._doc_id[1]); | |
| 198 | - Assert.AreEqual(0, response.status_code); | |
| 199 | - | |
| 200 | - // get list on a | |
| 201 | - linkresp = this._kt.get_document_links(this._session, this._doc_id[0]); | |
| 202 | - Assert.AreEqual(0, linkresp.status_code); | |
| 203 | - // TODO: length test | |
| 204 | - //Assert.IsTrue(linkresp.links.length == 1); | |
| 205 | - | |
| 206 | - Assert.AreEqual("kt unit test3", linkresp.links[0].title); | |
| 207 | - Assert.IsTrue(linkresp.links[0].document_id == this._doc_id[0]); | |
| 208 | - } | |
| 209 | - | |
| 210 | - [Test] | |
| 211 | - public void CheckoutBase64Document() | |
| 212 | - { | |
| 213 | - if (this._skip) return; | |
| 214 | - | |
| 215 | - | |
| 216 | - // checkout a | |
| 217 | - kt_response response = this._kt.checkout_base64_document(this._session, this._doc_id[0], "unit test - going to undo", false); | |
| 218 | - Assert.AreEqual(0, response.status_code); | |
| 219 | - | |
| 220 | - // undocheckout | |
| 221 | - response = this._kt.undo_document_checkout(this._session, this._doc_id[0], "unit test - doing undo"); | |
| 222 | - Assert.AreEqual(0, response.status_code); | |
| 223 | - | |
| 224 | - // todo: download and compare with original | |
| 225 | - | |
| 226 | - | |
| 227 | - // checkout a | |
| 228 | - response = this._kt.checkout_base64_document(this._session, this._doc_id[0], "unit test - going to checkin", false); | |
| 229 | - Assert.AreEqual(0, response.status_code); | |
| 230 | - | |
| 231 | - // todo: change | |
| 232 | - | |
| 233 | - // checkin a | |
| 234 | - kt_document_detail checkin = this._kt.checkin_base64_document(this._session, this._doc_id[0], "kt_unit_test1", "unit test - doing checkin", ConvertFileToBase64Encoding(FILE1_NAME), false); | |
| 235 | - Assert.AreEqual(0, checkin.status_code); | |
| 236 | - | |
| 237 | - // todo: download and compare with original | |
| 238 | - | |
| 239 | - } | |
| 240 | - | |
| 241 | - [Test] | |
| 242 | - public void CheckoutDocument() | |
| 243 | - { | |
| 244 | - if (this._skip) return; | |
| 245 | - // TODO - must deal with the more complex scenario | |
| 246 | - } | |
| 247 | - | |
| 248 | - | |
| 249 | - [Test] | |
| 250 | - public void ChangeDocumentOwner() | |
| 251 | - { | |
| 252 | - if (this._skip) return; | |
| 253 | - kt_response response = this._kt.change_document_owner(this._session, this._doc_id[0], NEW_OWNER, "just trying"); | |
| 254 | - Assert.AreEqual(0, response.status_code); | |
| 255 | - | |
| 256 | - | |
| 257 | - // get document info - validate | |
| 258 | - kt_document_detail detail = this._kt.get_document_detail(this._session, this._doc_id[0]); | |
| 259 | - Assert.AreEqual(0, detail.status_code); | |
| 260 | - // TODO: if we had the owner field, we could validate it | |
| 261 | - //Assert.AreEqual(NEW_OWNER, detail.owner); | |
| 262 | - } | |
| 263 | - | |
| 264 | - [Test] | |
| 265 | - public void ChangeDocumentType() | |
| 266 | - { | |
| 267 | - if (this._skip) return; | |
| 268 | - kt_response response = this._kt.change_document_type(this._session, this._doc_id[0], NEW_DOCUMENT_TYPE); | |
| 269 | - Assert.AreEqual(0, response.status_code); | |
| 270 | - | |
| 271 | - | |
| 272 | - // get document info - validate | |
| 273 | - kt_document_detail detail = this._kt.get_document_detail(this._session, this._doc_id[0]); | |
| 274 | - Assert.AreEqual(0, response.status_code); | |
| 275 | - Assert.AreEqual(NEW_DOCUMENT_TYPE, detail.document_type); | |
| 276 | - } | |
| 277 | - | |
| 278 | - [Test] | |
| 279 | - public void CopyDocument() | |
| 280 | - { | |
| 281 | - if (this._skip) return; | |
| 282 | - // TODO copy document | |
| 283 | - // get document info by name - validate | |
| 284 | - } | |
| 285 | - | |
| 286 | - [Test] | |
| 287 | - public void MoveDocument() | |
| 288 | - { | |
| 289 | - if (this._skip) return; | |
| 290 | - // TODO move document | |
| 291 | - // get document info by name - validate | |
| 292 | - } | |
| 293 | - | |
| 294 | - [Test] | |
| 295 | - public void DownloadDocument() | |
| 296 | - { | |
| 297 | - if (this._skip) return; | |
| 298 | - // TODO download document | |
| 299 | - // get document info by name - validate | |
| 300 | - } | |
| 301 | - | |
| 302 | - | |
| 303 | - [Test] | |
| 304 | - public void Workflow() | |
| 305 | - { | |
| 306 | - if (this._skip) return; | |
| 307 | - // start workflow | |
| 308 | - kt_response response = this._kt.start_document_workflow(this._session, this._doc_id[0], NEW_WORKFLOW); | |
| 309 | - Assert.AreEqual(0, response.status_code); | |
| 310 | - | |
| 311 | - // get document info - validate | |
| 312 | - kt_document_detail detail = this._kt.get_document_detail(this._session, this._doc_id[0]); | |
| 313 | - Assert.AreEqual(0, detail.status_code); | |
| 314 | - Assert.AreEqual(NEW_WORKFLOW, detail.workflow); | |
| 315 | - | |
| 316 | - // stop workflow | |
| 317 | - response = this._kt.delete_document_workflow(this._session, this._doc_id[0]); | |
| 318 | - Assert.AreEqual(0, response.status_code); | |
| 319 | - | |
| 320 | - // get document info - validate | |
| 321 | - detail = this._kt.get_document_detail(this._session, this._doc_id[0]); | |
| 322 | - Assert.AreEqual(0, detail.status_code); | |
| 323 | - Assert.AreEqual("", detail.workflow); | |
| 324 | - | |
| 325 | - | |
| 326 | - // get workflow state - | |
| 327 | - response = this._kt.get_document_workflow_state(this._session, this._doc_id[0]); | |
| 328 | - Assert.AreEqual(0, detail.status_code); | |
| 329 | - Assert.AreEqual(NEW_WORKFLOW, detail.workflow); | |
| 330 | - Assert.AreEqual(NEW_WORKFLOW_START, detail.workflow_state); | |
| 331 | - | |
| 332 | - | |
| 333 | - // get workflow transitions - maybe we should merge the two functions | |
| 334 | - kt_workflow_transitions_response trans_resp = this._kt.get_document_workflow_transitions(this._session, this._doc_id[0]); | |
| 335 | - Assert.AreEqual(0, trans_resp.status_code); | |
| 336 | - | |
| 337 | - | |
| 338 | - | |
| 339 | - // start workflow | |
| 340 | - response = this._kt.start_document_workflow(this._session, this._doc_id[0], NEW_WORKFLOW); | |
| 341 | - Assert.AreEqual(0, response.status_code); | |
| 342 | - | |
| 343 | - // do transition | |
| 344 | - response = this._kt.perform_document_workflow_transition(this._session, this._doc_id[0], NEW_TRANSITION, "unit test - transition 1"); | |
| 345 | - Assert.AreEqual(0, response.status_code); | |
| 346 | - | |
| 347 | - detail = this._kt.get_document_detail(this._session, this._doc_id[0]); | |
| 348 | - Assert.AreEqual(0, detail.status_code); | |
| 349 | - Assert.AreEqual(NEW_WORKFLOW, detail.workflow); | |
| 350 | - Assert.AreEqual(NEW_WORKFLOW_STATE, detail.workflow_state); | |
| 351 | - | |
| 352 | - | |
| 353 | - } | |
| 354 | - | |
| 355 | - [Test] | |
| 356 | - public void Metadata() | |
| 357 | - { | |
| 358 | - if (this._skip) return; | |
| 359 | - // get document types | |
| 360 | - kt_document_types_response doc_types = this._kt.get_document_types(this._session); | |
| 361 | - Assert.AreEqual(0, doc_types.status_code); | |
| 362 | - | |
| 363 | - // get document type metadata | |
| 364 | - kt_metadata_response metadata = this._kt.get_document_type_metadata(this._session, "Default"); | |
| 365 | - Assert.AreEqual(0, metadata.status_code); | |
| 366 | - | |
| 367 | - // get document metadata | |
| 368 | - metadata = this._kt.get_document_metadata(this._session, this._doc_id[0]); | |
| 369 | - Assert.AreEqual(0, metadata.status_code); | |
| 370 | - | |
| 371 | - // update document metadata | |
| 372 | - | |
| 373 | - kt_metadata_fieldset[] fs = new kt_metadata_fieldset[1]; | |
| 374 | - fs[0].fieldset = "Invoice"; | |
| 375 | - fs[0].fields = new kt_metadata_field[2]; | |
| 376 | - fs[0].fields[0].name = "Invoice No"; | |
| 377 | - fs[0].fields[0].value = "000010"; | |
| 378 | - fs[0].fields[1].name = "Invoice Date"; | |
| 379 | - fs[0].fields[1].value = "2007-10-12"; | |
| 380 | - | |
| 381 | - kt_response update_resp = this._kt.update_document_metadata(this._session, this._doc_id[0], fs); | |
| 382 | - Assert.AreEqual(0, update_resp.status_code); | |
| 383 | - | |
| 384 | - | |
| 385 | - | |
| 386 | - // get document metadata | |
| 387 | - metadata = this._kt.get_document_metadata(this._session, this._doc_id[0]); | |
| 388 | - Assert.AreEqual(0, metadata.status_code); | |
| 389 | - | |
| 390 | - } | |
| 391 | - | |
| 392 | - [Test] | |
| 393 | - public void History() | |
| 394 | - { | |
| 395 | - if (this._skip) return; | |
| 396 | - kt_document_version_history_response version_resp = this._kt.get_document_version_history(this._session, this._doc_id[0]); | |
| 397 | - Assert.AreEqual(0, version_resp.status_code); | |
| 398 | - | |
| 399 | - kt_document_transaction_history_response history_resp = this._kt.get_document_transaction_history(this._session, this._doc_id[0]); | |
| 400 | - Assert.AreEqual(0, history_resp.status_code); | |
| 401 | - } | |
| 402 | - | |
| 403 | - [Test] | |
| 404 | - public void Rename() | |
| 405 | - { | |
| 406 | - if (this._skip) return; | |
| 407 | - kt_response response = this._kt.rename_document_filename(this._session, this._doc_id[0], NEW_DOCUMENT_FILENAME); | |
| 408 | - Assert.AreEqual(0, response.status_code); | |
| 409 | - | |
| 410 | - // get document info - validate | |
| 411 | - kt_document_detail detail = this._kt.get_document_detail(this._session, this._doc_id[0]); | |
| 412 | - Assert.AreEqual(0, response.status_code); | |
| 413 | - Assert.AreEqual(NEW_DOCUMENT_FILENAME, detail.filename); | |
| 414 | - | |
| 415 | - | |
| 416 | - response = this._kt.rename_document_filename(this._session, this._doc_id[0], NEW_DOCUMENT_TITLE); | |
| 417 | - Assert.AreEqual(0, response.status_code); | |
| 418 | - | |
| 419 | - // get document info - validate | |
| 420 | - detail = this._kt.get_document_detail(this._session, this._doc_id[0]); | |
| 421 | - Assert.AreEqual(0, response.status_code); | |
| 422 | - Assert.AreEqual(NEW_DOCUMENT_TITLE, detail.filename); | |
| 423 | - } | |
| 424 | - | |
| 425 | - | |
| 426 | - | |
| 427 | - public static void writeFile(String filename, String text) | |
| 428 | - { | |
| 429 | - try | |
| 430 | - { | |
| 431 | - TextWriter tw = new StreamWriter(filename); | |
| 432 | - tw.WriteLine(text ); | |
| 433 | - tw.Close(); | |
| 434 | - } | |
| 435 | - catch (System.Exception exp) | |
| 436 | - { | |
| 437 | - System.Console.WriteLine("{0}", exp.Message); | |
| 438 | - throw; | |
| 439 | - } | |
| 440 | - } | |
| 441 | - | |
| 442 | - public static String readFile(String filename) | |
| 443 | - { | |
| 444 | - String text = null; | |
| 445 | - try | |
| 446 | - { | |
| 447 | - FileStream inFile = new FileStream("path.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read); | |
| 448 | - StreamReader sr = new StreamReader(inFile); | |
| 449 | - text = sr.ReadToEnd(); | |
| 450 | - inFile.Close(); | |
| 451 | - } | |
| 452 | - catch (System.Exception exp) | |
| 453 | - { | |
| 454 | - System.Console.WriteLine("{0}", exp.Message); | |
| 455 | - throw; | |
| 456 | - } | |
| 457 | - | |
| 458 | - return text; | |
| 459 | - } | |
| 460 | - | |
| 461 | - public static void deleteFile(string filename) | |
| 462 | - { | |
| 463 | - try | |
| 464 | - { | |
| 465 | - File.Delete(filename); | |
| 466 | - } | |
| 467 | - catch(System.Exception) | |
| 468 | - { | |
| 469 | - // we are using this to cleanup, so don't handle | |
| 470 | - } | |
| 471 | - } | |
| 472 | - | |
| 473 | - public static string ConvertFileToBase64Encoding(string filename) | |
| 474 | - { | |
| 475 | - System.IO.FileStream inFile; | |
| 476 | - | |
| 477 | - byte[] binaryData; | |
| 478 | - string base64String = ""; | |
| 479 | - | |
| 480 | - try | |
| 481 | - { | |
| 482 | - inFile = new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read); | |
| 483 | - binaryData = new Byte[inFile.Length]; | |
| 484 | - inFile.Read(binaryData, 0, (int)inFile.Length); | |
| 485 | - inFile.Close(); | |
| 486 | - | |
| 487 | - base64String = System.Convert.ToBase64String(binaryData, 0, binaryData.Length); | |
| 488 | - } | |
| 489 | - catch (System.Exception exp) | |
| 490 | - { | |
| 491 | - System.Console.WriteLine("{0}", exp.Message); | |
| 492 | - throw; | |
| 493 | - } | |
| 494 | - | |
| 495 | - return base64String; | |
| 496 | - } | |
| 497 | - | |
| 498 | - } | |
| 499 | - | |
| 500 | -} |