document_workflow.cs
3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using NUnit.Framework;
using System;
using System.IO;
namespace MonoTests.KnowledgeTree
{
[TestFixture]
public class WorkflowTest
{
private String _session;
private KnowledgeTreeService _kt;
private int _folderId;
private bool _verbose;
private Document _doc1;
[SetUp]
public void SetUp()
{
this._kt = new KnowledgeTreeService();
kt_response response = this._kt.login("admin","admin","127.0.0.1");
this._session = response.message;
this._folderId = 1;
this._doc1 = new Document(1, this._session, this._kt, this._verbose, false);
this._doc1.createFile(this._folderId);
this._verbose = true;
}
[TearDown]
public void TearDown()
{
this._doc1.deleteFile();
this._kt.logout(this._session);
}
[Test]
public void NonExistantWorkflowTest()
{
kt_document_detail response = this._kt.start_document_workflow(this._session, this._doc1.docId, "Non Existant Workflow");
Assert.IsTrue(0 != response.status_code);
}
[Test]
public void StartWorkflowTest()
{
kt_document_detail response = this._kt.start_document_workflow(this._session, this._doc1.docId, "Review Process");
Assert.AreEqual(0, response.status_code);
Assert.AreEqual("Review Process", response.workflow);
}
[Test]
public void StopWorkflowTest()
{
kt_document_detail response = this._kt.start_document_workflow(this._session, this._doc1.docId, "Review Process");
Assert.AreEqual(0, response.status_code);
Assert.AreEqual("Review Process", response.workflow);
response = this._kt.delete_document_workflow(this._session, this._doc1.docId);
Assert.AreEqual(0, response.status_code);
Assert.AreEqual("n/a", response.workflow);
}
[Test]
public void GetTransitionsTest()
{
kt_document_detail response = this._kt.start_document_workflow(this._session, this._doc1.docId, "Review Process");
Assert.AreEqual(0, response.status_code);
Assert.AreEqual("Review Process", response.workflow);
kt_workflow_transitions_response trans_resp = this._kt.get_document_workflow_transitions(this._session, this._doc1.docId);
Assert.AreEqual(0, trans_resp.status_code);
Assert.AreEqual(1, trans_resp.transitions.Length);
Assert.AreEqual("Request Approval", trans_resp.transitions[0]);
}
[Test]
public void WorkflowTransitionTest()
{
kt_document_detail response = this._kt.start_document_workflow(this._session, this._doc1.docId, "Review Process");
Assert.AreEqual(0, response.status_code);
Assert.AreEqual("Review Process", response.workflow);
Assert.AreEqual("Draft", response.workflow_state);
response = this._kt.perform_document_workflow_transition(this._session, this._doc1.docId, "Request Approval", "Please approve me");
Assert.AreEqual(0, response.status_code);
Assert.AreEqual("Review Process", response.workflow);
Assert.AreEqual("Approval", response.workflow_state);
response = this._kt.perform_document_workflow_transition(this._session, this._doc1.docId, "Approve", "Ok!");
Assert.AreEqual(0, response.status_code);
Assert.AreEqual("Review Process", response.workflow);
Assert.AreEqual("Published", response.workflow_state);
}
}
}