|
@@ -15,6 +15,27 @@ |
15 |
15 |
|
/// </summary> |
16 |
16 |
|
private const int SmithEnterprisesOrganisationId = 19483007; |
17 |
17 |
|
|
|
18 |
+ |
private static IApi _api; |
|
19 |
+ |
|
|
20 |
+ |
/// <summary> |
|
21 |
+ |
/// Test class initialise. |
|
22 |
+ |
/// </summary> |
|
23 |
+ |
/// <param name="context">The context.</param> |
|
24 |
+ |
[ClassInitialize] |
|
25 |
+ |
public static void ContactTestsInitialise(TestContext context) |
|
26 |
+ |
{ |
|
27 |
+ |
_api = new InsightlyAPI(APIUser.PLAIN_API_KEY); |
|
28 |
+ |
} |
|
29 |
+ |
|
|
30 |
+ |
/// <summary> |
|
31 |
+ |
/// Test class cleanup. |
|
32 |
+ |
/// </summary> |
|
33 |
+ |
[ClassCleanup] |
|
34 |
+ |
public static void ContactTestsCleanup() |
|
35 |
+ |
{ |
|
36 |
+ |
_api = null; |
|
37 |
+ |
} |
|
38 |
+ |
|
18 |
39 |
|
#region Get |
19 |
40 |
|
|
20 |
41 |
|
/// <summary> |
|
@@ -23,9 +44,7 @@ |
23 |
44 |
|
[TestMethod] |
24 |
45 |
|
public void GetSmithEnterprisesForCRMOrganisationId() |
25 |
46 |
|
{ |
26 |
|
- |
IApi api = new InsightlyAPI(APIUser.PLAIN_API_KEY); |
27 |
|
- |
|
28 |
|
- |
var organisation = api.GetOrganisation(SmithEnterprisesOrganisationId); |
|
47 |
+ |
var organisation = _api.GetOrganisation(SmithEnterprisesOrganisationId); |
29 |
48 |
|
|
30 |
49 |
|
Assert.IsNotNull(organisation); |
31 |
50 |
|
Assert.IsInstanceOfType(organisation, typeof(Organisation)); |
|
@@ -38,9 +57,7 @@ |
38 |
57 |
|
[TestMethod] |
39 |
58 |
|
public void GetBasicOrganisationDetails() |
40 |
59 |
|
{ |
41 |
|
- |
IApi api = new InsightlyAPI(APIUser.PLAIN_API_KEY); |
42 |
|
- |
|
43 |
|
- |
var orgs = api.GetOrganisations(false); |
|
60 |
+ |
var orgs = _api.GetOrganisations(false); |
44 |
61 |
|
|
45 |
62 |
|
Assert.IsTrue(orgs.Count > 0); |
46 |
63 |
|
Assert.IsNull(orgs[0].ADDRESSES); |
|
@@ -52,9 +69,7 @@ |
52 |
69 |
|
[TestMethod] |
53 |
70 |
|
public void GetFullOrganisationDetails() |
54 |
71 |
|
{ |
55 |
|
- |
IApi api = new InsightlyAPI(APIUser.PLAIN_API_KEY); |
56 |
|
- |
|
57 |
|
- |
var orgs = api.GetOrganisations(true); |
|
72 |
+ |
var orgs = _api.GetOrganisations(true); |
58 |
73 |
|
|
59 |
74 |
|
Assert.IsTrue(orgs.Count > 0); |
60 |
75 |
|
Assert.IsNotNull(orgs[0].ADDRESSES); |
|
@@ -66,10 +81,9 @@ |
66 |
81 |
|
[TestMethod] |
67 |
82 |
|
public void GetOrganisationByName() |
68 |
83 |
|
{ |
69 |
|
- |
IApi api = new InsightlyAPI(APIUser.PLAIN_API_KEY); |
70 |
84 |
|
const string testName = "Smith Enterprises"; |
71 |
85 |
|
|
72 |
|
- |
var orgs = api.GetOrganisationsForName(testName); |
|
86 |
+ |
var orgs = _api.GetOrganisationsForName(testName); |
73 |
87 |
|
Assert.IsTrue(orgs.Count > 0); |
74 |
88 |
|
|
75 |
89 |
|
Organisation namedOrg = orgs[0]; |
|
@@ -88,21 +102,20 @@ |
88 |
102 |
|
public void AddBasicOrganisationRecord() |
89 |
103 |
|
{ |
90 |
104 |
|
Organisation addedOrg = null; |
91 |
|
- |
IApi api = new InsightlyAPI(APIUser.PLAIN_API_KEY); |
92 |
105 |
|
|
93 |
106 |
|
try |
94 |
107 |
|
{ |
95 |
108 |
|
Organisation newOrg = new Organisation(); |
96 |
109 |
|
newOrg.ORGANISATION_NAME = "Kodak Picture Inc."; |
97 |
110 |
|
|
98 |
|
- |
addedOrg = api.AddNewOrganisation(newOrg); |
|
111 |
+ |
addedOrg = _api.AddNewOrganisation(newOrg); |
99 |
112 |
|
|
100 |
113 |
|
Assert.IsNotNull(addedOrg); |
101 |
114 |
|
Assert.AreEqual(newOrg.ORGANISATION_NAME, addedOrg.ORGANISATION_NAME); |
102 |
115 |
|
} |
103 |
116 |
|
finally |
104 |
117 |
|
{ |
105 |
|
- |
DeleteOrganisation(api, addedOrg); |
|
118 |
+ |
DeleteOrganisation(addedOrg); |
106 |
119 |
|
} |
107 |
120 |
|
} |
108 |
121 |
|
|
|
@@ -121,15 +134,14 @@ |
121 |
134 |
|
/// <summary> |
122 |
135 |
|
/// Deletes the organisation. |
123 |
136 |
|
/// </summary> |
124 |
|
- |
/// <param name="api">The API.</param> |
125 |
137 |
|
/// <param name="organisation">The organisation.</param> |
126 |
|
- |
private void DeleteOrganisation(IApi api, Organisation organisation) |
|
138 |
+ |
private void DeleteOrganisation(Organisation organisation) |
127 |
139 |
|
{ |
128 |
140 |
|
try |
129 |
141 |
|
{ |
130 |
142 |
|
if (organisation != null && organisation.ORGANISATION_ID > 0) |
131 |
143 |
|
{ |
132 |
|
- |
api.DeleteOrganisation(organisation.ORGANISATION_ID); |
|
144 |
+ |
_api.DeleteOrganisation(organisation.ORGANISATION_ID); |
133 |
145 |
|
} |
134 |
146 |
|
} |
135 |
147 |
|
catch (Exception) |