-
-
Notifications
You must be signed in to change notification settings - Fork 360
/
Copy pathAuthenticationSystemTests.cs
47 lines (42 loc) · 1.58 KB
/
AuthenticationSystemTests.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
using Exercism.Tests;
public class AuthenticationSystemTests
{
[Fact]
[Task(4)]
public void GetAdmin()
{
var admin = new Identity { EyeColor = "green", Email = "[email protected]" };
var authenticator = new Authenticator(admin);
Assert.Equal(admin, authenticator.Admin);
}
[Fact]
[Task(4)]
public void CheckAdminCannotBeTampered()
{
var adminEmail = "[email protected]";
var admin = new Identity { EyeColor = "green", Email = adminEmail };
var authenticator = new Authenticator(admin);
var tamperedAdmin = authenticator.Admin;
tamperedAdmin.Email = "[email protected]";
Assert.Equal(adminEmail, authenticator.Admin.Email);
}
[Fact]
[Task(5)]
public void GetDevelopers()
{
var authenticator = new Authenticator(new Identity { EyeColor = "green", Email = "[email protected]" });
var devs = authenticator.GetDevelopers() as IDictionary<string, Identity>;
bool?[] actual = { devs != null, devs?.Count == 2, devs?["Anders"].EyeColor == "brown" };
bool?[] expected = { true, true, true };
Assert.Equal(expected, actual);
}
[Fact]
[Task(5)]
public void CheckDevelopersCannotBeTampered()
{
var authenticator = new Authenticator(new Identity { EyeColor = "green", Email = "[email protected]" });
IDictionary<string, Identity> devs = authenticator.GetDevelopers();
Identity tamperedDev = new Identity { EyeColor = "grey", Email = "[email protected]" };
Assert.Throws<NotSupportedException>(() => devs["Anders"] = tamperedDev);
}
}