-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathAuditLogTest.cs
More file actions
86 lines (70 loc) · 3.47 KB
/
Copy pathAuditLogTest.cs
File metadata and controls
86 lines (70 loc) · 3.47 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
using System;
using AutoFixture;
using Contentstack.Management.Core.Models;
using Contentstack.Management.Core.Unit.Tests.Mokes;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Contentstack.Management.Core.Unit.Tests.Models
{
public class AuditLogTest
{
private Stack _stack;
private readonly IFixture _fixture = new Fixture();
private ContentstackResponse _contentstackResponse;
[TestInitialize]
public void initialize()
{
var client = new ContentstackClient();
_contentstackResponse = MockResponse.CreateContentstackResponse("MockResponse.txt");
client.ContentstackPipeline.ReplaceHandler(new MockHttpHandler(_contentstackResponse));
client.contentstackOptions.Authtoken = _fixture.Create<string>();
_stack = new Stack(client, _fixture.Create<string>());
}
[TestMethod]
public void Initialize_AuditLog()
{
AuditLog auditLog = new AuditLog(_stack, null);
Assert.IsNull(auditLog.Uid);
Assert.AreEqual($"/audit-logs", auditLog.resourcePath);
Assert.ThrowsException<InvalidOperationException>(() => auditLog.Fetch());
Assert.ThrowsExceptionAsync<InvalidOperationException>(() => auditLog.FetchAsync());
}
[TestMethod]
public void Initialize_AuditLog_With_Uid()
{
string uid = _fixture.Create<string>();
AuditLog auditLog = new AuditLog(_stack, uid);
Assert.AreEqual(uid, auditLog.Uid);
Assert.AreEqual($"/audit-logs/{auditLog.Uid}", auditLog.resourcePath);
Assert.ThrowsException<InvalidOperationException>(() => auditLog.FindAll());
Assert.ThrowsExceptionAsync<InvalidOperationException>(() => auditLog.FindAllAsync());
}
[TestMethod]
public void Should_Fetch_AuditLog()
{
ContentstackResponse response = _stack.AuditLog(_fixture.Create<string>()).Fetch();
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJsonObjectResponse().ToString(), response.OpenJsonObjectResponse().ToString());
}
[TestMethod]
public async System.Threading.Tasks.Task Should_Fetch_AuditLog_Async()
{
ContentstackResponse response = await _stack.AuditLog(_fixture.Create<string>()).FetchAsync();
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJsonObjectResponse().ToString(), response.OpenJsonObjectResponse().ToString());
}
[TestMethod]
public void Should_Find_AuditLog()
{
ContentstackResponse response = _stack.AuditLog().FindAll();
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJsonObjectResponse().ToString(), response.OpenJsonObjectResponse().ToString());
}
[TestMethod]
public async System.Threading.Tasks.Task Should_Find_AuditLog_Async()
{
ContentstackResponse response = await _stack.AuditLog().FindAllAsync();
Assert.AreEqual(_contentstackResponse.OpenResponse(), response.OpenResponse());
Assert.AreEqual(_contentstackResponse.OpenJsonObjectResponse().ToString(), response.OpenJsonObjectResponse().ToString());
}
}
}