-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateServerObjectTests.cs
More file actions
252 lines (187 loc) · 11.2 KB
/
CreateServerObjectTests.cs
File metadata and controls
252 lines (187 loc) · 11.2 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
using System;
using System.Threading.Tasks;
using EssSharp.Integration.Setup;
using Xunit;
using Xunit.Abstractions;
namespace EssSharp.Integration
{
/// <summary>
/// Tests collection definition with <see cref="CollectionPriorityAttribute" /> for <see cref="TestCollectionOrderer" />
/// </summary>
[CollectionDefinition(nameof(CreateServerObjectTests), DisableParallelization = true), CollectionPriority(4)]
public class CreateServerObjectTestsCollection : ICollectionFixture<CollectionFixture> { }
/// <summary>
/// Tests for ability to create server objects/stand up a server for subsequent testing.
/// </summary>
[Collection(nameof(CreateServerObjectTests)), Trait("type", "create")]
public class CreateServerObjectTests : IntegrationTestBase
{
/// <summary />
/// <param name="output" />
public CreateServerObjectTests( ITestOutputHelper output ) : base(output) { }
[Fact(DisplayName = "CreateServerObjectTests - 01 - Essbase_AfterClean_CanCreateSampleApplications"), Priority(01)]
public async Task Essbase_AfterClean_CanCreateSampleApplications()
{
// Get an unconnected server.
var server = GetEssServer();
// Get the list of applications.
var applications = await server.GetApplicationsAsync();
// Assert that server contains no applications before we create them.
Assert.Empty(applications);
// Get the application workbook for Sample.Basic.
var sampleWorkbook = await server.GetFileAsync(@"/gallery/Applications/Demo Samples/Block Storage/Sample_Basic.xlsx");
// Create the application.
await server.CreateApplicationFromWorkbookAsync("Sample", "Basic", new EssJobImportExcelOptions(sampleWorkbook, buildOption: EssBuildOption.NONE));
// Get the application workbook for Demo.Basic.
var demoWorkbook = await server.GetFileAsync(@"/gallery/Applications/Demo Samples/Block Storage/Demo_Basic.xlsx");
// Create the application.
await server.CreateApplicationFromWorkbookAsync("Demo", "Basic", new EssJobImportExcelOptions(demoWorkbook, buildOption: EssBuildOption.NONE));
// Get the application workbook and data file for ASOSamp.Basic.
var asoSampleWorkbook = await server.GetFileAsync(@"/gallery/Applications/Demo Samples/Aggregate Storage/ASO_Sample.xlsx");
var asoSampleDataFile = await server.GetFileAsync(@"/gallery/Applications/Demo Samples/Aggregate Storage/ASO_Sample_Data.txt");
// Create the application and get the Basic cube.
var asoSample = await server.CreateApplicationFromWorkbookAsync("ASOSamp", "Basic", new EssJobImportExcelOptions(asoSampleWorkbook, buildOption: EssBuildOption.NONE, loadData: false))
.GetCubeAsync("Basic");
// Load the data into the Basic cube.
await asoSample.LoadDataToCubeAsync(new EssJobLoadDataOptions(essDataFile: asoSampleDataFile));
// Get the list of applications.
applications = await server.GetApplicationsAsync();
// Assert that server now contains 3 applications (Sample, Demo, and ASOSamp).
Assert.Equal(3, applications?.Count);
}
[Fact(DisplayName = @"CreateServerObjectTests - 02 - Essbase_AfterClean_CanCreateGroup"), Priority(02)]
public async Task Essbase_AfterClean_CanCreateGroups()
{
// Get an unconnected server.
var server = GetEssServer();
// TODO: create Group Creation Class and a proper To
// Create group one
var group1 = await server.CreateGroupAsync("Test_Group", EssServerRole.PowerUser, "test group");
// Create group 2 - will add to group one in PerformServerFunctionTest
var group2 = await server.CreateGroupAsync("Test_Group_2", EssServerRole.PowerUser, "test group 2");
// Assert that the group name, role, and description is correct is correct
Assert.Equal("Test_Group", group1.Name);
Assert.Equal(EssServerRole.PowerUser, group1.Role);
Assert.Equal("test group", group1.Description);
Assert.Equal("Test_Group_2", group2.Name);
Assert.Equal(EssServerRole.PowerUser, group2.Role);
Assert.Equal("test group 2", group2.Description);
}
[Fact(DisplayName = "CreateServerObjectTests - 03 - Essbase_AfterCubeCreation_CanCreateUser"), Priority(03)]
public async Task Essbase_AfterCubeCreation_CanCreateUser()
{
// Get an unconnected server.
var server = GetEssServer();
var userConnection = GetEssConnection(EssServerRole.User);
// Create EssUserCreationOptions
var options = new EssUserCreationOptions(userConnection.Username, userConnection.Password, userConnection.Role);
var newUser = await server.CreateUserAsync(options);
Assert.Equal(userConnection.Username, newUser.Name);
Assert.Equal(userConnection.Role, newUser.Role);
}
[Fact(DisplayName = "CreateServerObjectTests - 04 - Essbase_AfterCubeCreation_CanCreateUserPermissions"), Priority(04)]
public async Task Essbase_AfterCubeCreation_CanCreateUserPermissions()
{
// Get an unconnected server.
var server = GetEssServer();
var userConnection = GetEssConnection(EssServerRole.User);
var app = await server.GetApplicationAsync("Sample");
var userPermissions = await app.CreatePermissionsAsync(userConnection.Username, EssApplicationRole.db_access);
Assert.Equal(EssApplicationRole.db_access, userPermissions.Role);
Assert.Equal(userConnection.Username, userPermissions.Name);
}
[Fact(DisplayName = "CreateServerObjectTests - 05 - Essbase_AfterCubeCreation_CanCreateGroupPermissions"), Priority(05)]
public async Task Essbase_AfterCubeCreation_CanCreateGroupPermissions()
{
// Get an unconnected server.
var server = GetEssServer();
var group = await server.GetGroupAsync("Test_Group");
var app = await server.GetApplicationAsync("Sample");
var groupPermissions = await app.CreatePermissionsAsync(group.Name, EssApplicationRole.db_update, true);
Assert.Equal(EssApplicationRole.db_update, groupPermissions.Role);
Assert.Equal("Test_Group", groupPermissions.Name);
}
[Fact(DisplayName = "CreateServerObjectTests - 05 - Essbase_AfterCubeCreation_CanCreateMdxScript"), Priority(05)]
public async Task Essbase_AfterCubeCreation_CanCreateMdxScript()
{
// Get an unconnected server.
var server = GetEssServer();
// Get the Sample.Basic cube.
var cube = await server.GetApplicationAsync("Sample")
.GetCubeAsync("Basic");
// Assert that the cube does not contain an MDX script called "test" before we create one.
Assert.DoesNotContain(collection: await cube.GetScriptsAsync<IEssMdxScript>(), mdx => string.Equals(mdx?.Name, "test", StringComparison.Ordinal));
// Create some script content.
var content = @"SELECT {[Market]} ON COLUMNS, {[YEAR]} ON ROWS";
// Create a script on the server with the given content.
await cube.CreateScriptAsync<IEssMdxScript>("test", content);
// Get the script back from the server.
var script = await cube.GetScriptAsync<IEssMdxScript>("test", getContent: true);
// Assert that the script exists and contains the content we gave it.
Assert.Equal(content, script?.Content);
}
[Fact(DisplayName = "CreateServerObjectTests - 06 - Essbase_AfterCubeCreation_CanCreateReportScript"), Priority(06)]
public async Task Essbase_AfterCubeCreation_CanCreateReportScript()
{
// Get an unconnected server.
var server = GetEssServer();
// Get the Sample.Basic cube.
var cube = await server.GetApplicationAsync("Sample")
.GetCubeAsync("Basic");
// Assert that the cube does not contain an report script called "test" before we create one.
Assert.DoesNotContain(collection: await cube.GetScriptsAsync<IEssReportScript>(), report => string.Equals(report?.Name, "test", StringComparison.Ordinal));
// Create some script content.
var content =
@"<PAGE(""Measures"")
""Sales""
<COLUMN(""Scenario"", ""Year"")
""Scenario""
""Jan"" ""Feb"" ""Mar"" ""Apr""
<ROW(""Market"", ""Product"")
""New York""
""Product"" ""100"" ""100-10""
!";
// Create a script on the server with the given content.
await cube.CreateScriptAsync<IEssReportScript>("test", content);
// Get the script back from the server.
var script = await cube.GetScriptAsync<IEssReportScript>("test", getContent: true);
// Assert that the script exists and contains the content we gave it.
Assert.Equal(content, script?.Content);
}
[Fact(DisplayName = "CreateServerObjectTests - 07 - Essbase_AfterCubeCreation_CanCreateMaxLScript"), Priority(07)]
public async Task Essbase_AfterCubeCreation_CanCreateMaxLScript()
{
// Get an unconnected server.
var server = GetEssServer();
// Get the Sample.Basic cube.
var cube = await server.GetApplicationAsync("Sample")
.GetCubeAsync("Basic");
// Assert that the cube does not contain an MaxL script called "test" before we create one.
Assert.DoesNotContain(collection: await cube.GetScriptsAsync<IEssMaxlScript>(), maxl => string.Equals(maxl?.Name, "test", StringComparison.Ordinal));
// Create some script content.
var content = @"query database sample.basic get dbstats dimension;";
// Create a script on the server with the given content.
await cube.CreateScriptAsync<IEssMaxlScript>("test", content);
// Get the script back from the server.
var script = await cube.GetScriptAsync<IEssMaxlScript>("test", getContent: true);
// Assert that the script exists and contains the content we gave it.
Assert.Equal(content, script?.Content);
}
[Fact(DisplayName = @"CreateServerObjectTests - 08 - Essbase_AfterCubeCreation_CanCreateLockOnScript"), Priority(08)]
public async Task Essbase_AfterCubeCreation_CanCreateLockOnScript()
{
// Get an unconnected server.
var server = GetEssServer();
// Get the "CalcAll" script from Sample.Basic.
var script = await server.GetApplicationAsync("Sample")
.GetCubeAsync("Basic")
.GetScriptAsync<IEssCalcScript>("CalcAll");
// Create lock options object.
var options = new EssLockOptions(script.Name, EssLockedFileType.CALCSCRIPT);
// Lock Script on server.
var lockedScript = await script.Cube.CreateLockObjectAsync(options);
// Assert that the lock object name is the same as the one we passed.
Assert.Equal("CalcAll", lockedScript.Name);
}
}
}