Created Unit Test Project

This commit is contained in:
Matthew Burke
2023-08-14 17:10:38 -04:00
parent 19153c9d02
commit 4a4bcc81e0
10 changed files with 167 additions and 51 deletions

View File

@@ -3,7 +3,7 @@ using System.Xml;
namespace PWAPPv2.Source
{
class APIConfig
public class APIConfig
{
public string PWUserID;
public string PWPassword;

View File

@@ -7,7 +7,7 @@ using System.Text;
namespace PWAPPv2.Source.API
{
class APIConnection
public class APIConnection
{
private static string BaseURL;
@@ -52,39 +52,6 @@ namespace PWAPPv2.Source.API
}
}
public string APIPost()
{
string text;
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://apipatientweb.azurewebsites.net/api/PWReferralTypes");
request.Method = "POST";
request.ContentType = "application/json; charset=\"utf-8\"";
request.Accept = "application/json";
string postData = Source.API.APIRequestBuilder.BuildJsonBodyRequest(Credentials);
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] data = encoding.GetBytes(postData);
request.ContentLength = data.Length;
Stream newStream = request.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
var response = (HttpWebResponse)request.GetResponse();
using (var sr = new StreamReader(response.GetResponseStream()))
{
text = sr.ReadToEnd();
}
}
catch (WebException wex)
{
text = new StreamReader(wex.Response.GetResponseStream()).ReadToEnd();
}
return text;
}
public string SendPostRequestAsync(string apiUri)
{
HttpClient client = new HttpClient();

View File

@@ -1,12 +1,17 @@
namespace PWAPPv2.Source.DataObjects
{
class APICredentials
public class APICredentials
{
public string UserID;
public string Password;
public string PracticeId;
public string APIid;
public APICredentials()
{
}
public APICredentials(Source.APIConfig config)
{
UserID = config.PWUserID;