| 1 | using System;
|
|---|
| 2 | using System.Collections.Generic;
|
|---|
| 3 | using System.Text;
|
|---|
| 4 | using IndianHealthService.BMXNet.WinForm.Configuration;
|
|---|
| 5 | using IndianHealthService.BMXNet.WinForm;
|
|---|
| 6 |
|
|---|
| 7 | namespace IndianHealthService.BMXNet.Tests
|
|---|
| 8 | {
|
|---|
| 9 | public class TestUser
|
|---|
| 10 | {
|
|---|
| 11 | public static String ReadAppConfig(String parentName, String aName, String aDefaultValue)
|
|---|
| 12 | {
|
|---|
| 13 | String hit = System.Configuration.ConfigurationManager.AppSettings[parentName + "." + aName];
|
|---|
| 14 |
|
|---|
| 15 | return (hit == null || (hit.Length == 0)) ? aDefaultValue : hit;
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | public static bool ReadAppConfig(String parentName, String aName, bool defaultValue)
|
|---|
| 19 | {
|
|---|
| 20 | return "True".Equals(ReadAppConfig(parentName, aName,defaultValue.ToString()), StringComparison.InvariantCultureIgnoreCase);
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | public static int ReadAppConfig(String parentName, String aName, int anInt)
|
|---|
| 24 | {
|
|---|
| 25 | String hit = ReadAppConfig(parentName, aName, "");
|
|---|
| 26 | if (hit.Length == 0)
|
|---|
| 27 | return anInt;
|
|---|
| 28 |
|
|---|
| 29 | int result = -1;
|
|---|
| 30 | int.TryParse(hit, out result);
|
|---|
| 31 | return result;
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | public static TestUser ReadFromAppConfig(String aName)
|
|---|
| 35 | {
|
|---|
| 36 | TestUser user = new TestUser();
|
|---|
| 37 | RpmsConnectionSpec connection = new RpmsConnectionSpec();
|
|---|
| 38 |
|
|---|
| 39 | connection.Server = ReadAppConfig("Default", "rpmsHost", "");
|
|---|
| 40 | connection.Port = ReadAppConfig("Default", "bmxPort", 0);
|
|---|
| 41 | connection.NameSpace = ReadAppConfig("Default", "namespace", "");
|
|---|
| 42 | connection.UseWindowsAuthentication = ReadAppConfig("Default", "useWinAuth", false);
|
|---|
| 43 |
|
|---|
| 44 | connection.Server = ReadAppConfig(aName, "rpmsHost", connection.Server);
|
|---|
| 45 | connection.Port = ReadAppConfig(aName, "bmxPort", connection.Port);
|
|---|
| 46 | connection.NameSpace = ReadAppConfig(aName, "namespace", connection.NameSpace);
|
|---|
| 47 | connection.UseWindowsAuthentication = ReadAppConfig(aName, "useWinAuth", connection.UseWindowsAuthentication);
|
|---|
| 48 |
|
|---|
| 49 | user.ConnectionSpec = connection;
|
|---|
| 50 | user.AccessCode = ReadAppConfig(aName, "accessCode", ReadAppConfig("Default", "accessCode", ""));
|
|---|
| 51 | user.VerifyCode = ReadAppConfig(aName, "verifyCode", ReadAppConfig("Default", "verifyCode", ""));
|
|---|
| 52 |
|
|---|
| 53 | return user;
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | private String _name = null;
|
|---|
| 57 |
|
|---|
| 58 | public String Name
|
|---|
| 59 | {
|
|---|
| 60 | get { return _name; }
|
|---|
| 61 | set { _name = value; }
|
|---|
| 62 | }
|
|---|
| 63 |
|
|---|
| 64 | private RpmsConnectionSpec _connectionSpec = null;
|
|---|
| 65 |
|
|---|
| 66 | public RpmsConnectionSpec ConnectionSpec
|
|---|
| 67 | {
|
|---|
| 68 | get { return _connectionSpec; }
|
|---|
| 69 | set { _connectionSpec = value; }
|
|---|
| 70 | }
|
|---|
| 71 | private String _accessCode = null;
|
|---|
| 72 |
|
|---|
| 73 | public String AccessCode
|
|---|
| 74 | {
|
|---|
| 75 | get { return _accessCode; }
|
|---|
| 76 | set { _accessCode = value; }
|
|---|
| 77 | }
|
|---|
| 78 | private String _verifyCode = null;
|
|---|
| 79 |
|
|---|
| 80 | public String VerifyCode
|
|---|
| 81 | {
|
|---|
| 82 | get { return _verifyCode; }
|
|---|
| 83 | set { _verifyCode = value; }
|
|---|
| 84 | }
|
|---|
| 85 |
|
|---|
| 86 | public bool Login(LoginProcess aProcess)
|
|---|
| 87 | {
|
|---|
| 88 | return aProcess.AttemptAccessVerifyLogin(this.ConnectionSpec, this.AccessCode, this.VerifyCode);
|
|---|
| 89 | }
|
|---|
| 90 | }
|
|---|
| 91 | }
|
|---|