/
TestKeychainHelpers.cs
70 lines (64 loc) · 1.95 KB
/
TestKeychainHelpers.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using NUnit.Framework;
using MonoTouch.Security;
namespace iOSPasswordStorage
{
[TestFixture]
public class TestKeychainHelpers
{
/// <summary>
/// Tests setting a password.
/// </summary>
[Test]
public void Test_10_SetPasswordForUsernameNotSyncable ()
{
var result = KeychainHelpers.SetPasswordForUsername ( "hallo@example.com", "my password", "myService", SecAccessible.Always, false );
Assert.That(result == MonoTouch.Security.SecStatusCode.Success);
}
/// <summary>
/// Tests getting a password.
/// </summary>
[Test]
public void Test_20_GetPasswordForUsernameNotSyncable ()
{
var result = KeychainHelpers.GetPasswordForUsername ("hallo@example.com", "myService", false);
Assert.That (result == "my password");
}
/// <summary>
/// Tests deleting a password.
/// </summary>
[Test]
public void Test_30_DeletePasswordForUsernameNotSyncable()
{
var result = KeychainHelpers.DeletePasswordForUsername ("hallo@example.com", "myService", false);
Assert.That (result == SecStatusCode.Success);
}
/// <summary>
/// Tests setting a password.
/// </summary>
[Test]
public void Test_40_SetPasswordForUsernameSyncable ()
{
var result = KeychainHelpers.SetPasswordForUsername ( "hallo@example.com", "my password", "myService", SecAccessible.Always, true );
Assert.That(result == MonoTouch.Security.SecStatusCode.Success);
}
/// <summary>
/// Tests getting a password.
/// </summary>
[Test]
public void Test_50_GetPasswordForUsernameSyncable ()
{
var result = KeychainHelpers.GetPasswordForUsername ("hallo@example.com", "myService", true);
Assert.That (result == "my password");
}
/// <summary>
/// Tests deleting a password.
/// </summary>
[Test]
public void Test_60_DeletePasswordForUsernameSyncable()
{
var result = KeychainHelpers.DeletePasswordForUsername ("hallo@example.com", "myService", true);
Assert.That (result == SecStatusCode.Success);
}
}
}