-
-
Notifications
You must be signed in to change notification settings - Fork 261
/
Copy pathObjectCoderTests.cs
49 lines (45 loc) · 1.7 KB
/
ObjectCoderTests.cs
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
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Parse;
using Parse.Infrastructure;
using Parse.Infrastructure.Data;
using Parse.Platform.Objects;
using System.Collections.Generic;
using System.Diagnostics;
[TestClass]
public class ObjectCoderTests
{
[TestMethod]
public void TestACLCoding()
{
// Prepare the mock service hub
var serviceHub = new ServiceHub(); // Mock or actual implementation depending on your setup
// Decode the ACL from a dictionary
MutableObjectState state = (MutableObjectState) ParseObjectCoder.Instance.Decode(new Dictionary<string, object>
{
["ACL"] = new Dictionary<string, object>
{
["ACL"] = new Dictionary<string, object>
{
["3KmCvT7Zsb"] = new Dictionary<string, object>
{
["read"] = true,
["write"] = true
},
["*"] = new Dictionary<string, object> { ["read"] = true }
}
}
}, default, serviceHub);
// Check that the ACL was properly decoded
ParseACL resultACL = state.ServerData["ACL"] as ParseACL;
Debug.WriteLine(resultACL is null);
// Assertions
Assert.IsTrue(state.ContainsKey("ACL"));
Assert.IsNotNull(resultACL);
Assert.IsTrue(resultACL.PublicReadAccess);
Assert.IsFalse(resultACL.PublicWriteAccess);
Assert.IsTrue(resultACL.GetWriteAccess("3KmCvT7Zsb"));
Assert.IsTrue(resultACL.GetReadAccess("3KmCvT7Zsb"));
Assert.IsFalse(resultACL.GetWriteAccess("*"));
Assert.IsTrue(resultACL.GetReadAccess("*"));
}
}