|
|
@ -60,4 +60,91 @@ void main() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
group('Account', () { |
|
|
|
|
|
|
|
final account = Account( |
|
|
|
|
|
|
|
serverURL: 'http://example.com', |
|
|
|
|
|
|
|
username: 'JohnDoe', |
|
|
|
|
|
|
|
password: 'super_secret', |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test('serialization', () { |
|
|
|
|
|
|
|
const json = { |
|
|
|
|
|
|
|
'serverURL': 'http://example.com', |
|
|
|
|
|
|
|
'username': 'JohnDoe', |
|
|
|
|
|
|
|
'password': 'super_secret', |
|
|
|
|
|
|
|
'userAgent': null, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(account.toJson(), equals(json)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(Account.fromJson(json), equals(account)); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test('id', () { |
|
|
|
|
|
|
|
expect(account.id, '8bcb507a406c5ad0eed4072601bcfdd2d923e87d'); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test('humanReadableID', () { |
|
|
|
|
|
|
|
expect(account.humanReadableID, 'JohnDoe@example.com'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final accountWithDefaultPort = Account( |
|
|
|
|
|
|
|
serverURL: 'http://example.com:80', |
|
|
|
|
|
|
|
username: 'JohnDoe', |
|
|
|
|
|
|
|
password: 'super_secret', |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(accountWithDefaultPort.humanReadableID, 'JohnDoe@example.com'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final accountWithPort = Account( |
|
|
|
|
|
|
|
serverURL: 'http://example.com:8080', |
|
|
|
|
|
|
|
username: 'JohnDoe', |
|
|
|
|
|
|
|
password: 'super_secret', |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(accountWithPort.humanReadableID, 'JohnDoe@example.com:8080'); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test('AccountFind', () { |
|
|
|
|
|
|
|
final account1 = Account( |
|
|
|
|
|
|
|
serverURL: 'http://example.com', |
|
|
|
|
|
|
|
username: 'JohnDoe', |
|
|
|
|
|
|
|
password: 'super_secret', |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
final account2 = Account( |
|
|
|
|
|
|
|
serverURL: 'http://example.com', |
|
|
|
|
|
|
|
username: 'JohnDoe2', |
|
|
|
|
|
|
|
password: 'super_secret', |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
final account3 = Account( |
|
|
|
|
|
|
|
serverURL: 'http://example.com', |
|
|
|
|
|
|
|
username: 'JohnDoe3', |
|
|
|
|
|
|
|
password: 'super_secret', |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
final account4 = Account( |
|
|
|
|
|
|
|
serverURL: 'http://example.com', |
|
|
|
|
|
|
|
username: 'JohnDoe4', |
|
|
|
|
|
|
|
password: 'super_secret', |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
final account5 = Account( |
|
|
|
|
|
|
|
serverURL: 'http://example.com', |
|
|
|
|
|
|
|
username: 'JohnDoe5', |
|
|
|
|
|
|
|
password: 'super_secret', |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
final accounts = { |
|
|
|
|
|
|
|
account1, |
|
|
|
|
|
|
|
account2, |
|
|
|
|
|
|
|
account3, |
|
|
|
|
|
|
|
account4, |
|
|
|
|
|
|
|
account5, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(accounts.tryFind(null), isNull); |
|
|
|
|
|
|
|
expect(accounts.tryFind('invalidID'), isNull); |
|
|
|
|
|
|
|
expect(accounts.tryFind(account3.id), equals(account3)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(() => accounts.find('invalidID'), throwsA(isA<StateError>())); |
|
|
|
|
|
|
|
expect(accounts.find(account3.id), equals(account3)); |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|