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
+1 -1
View File
@@ -69,7 +69,7 @@
<GroupBox Header="Refer To" HorizontalAlignment="Left" Height="55" Margin="0,120,0,0" VerticalAlignment="Top" Width="458" Grid.Column="1">
<ComboBox x:Name="boxReferTo" HorizontalAlignment="Left" Margin="0,10,-2,0" VerticalAlignment="Top" Width="448"/>
</GroupBox>
<CheckBox x:Name="contact" Content="Contact Doctor" HorizontalAlignment="Left" Margin="0,175,0,0" VerticalAlignment="Top" Grid.Column="1" Checked="CheckBox_Checked" Height="15" Width="101"/>
<CheckBox x:Name="contact" Content="Contact Patient" HorizontalAlignment="Left" Margin="0,175,0,0" VerticalAlignment="Top" Grid.Column="1" Checked="CheckBox_Checked" Height="15" Width="101"/>
<GroupBox Header="Remarks" HorizontalAlignment="Left" Height="150" Margin="10,347,0,0" VerticalAlignment="Top" Width="309">
<RichTextBox x:Name="fieldRemakrs" HorizontalAlignment="Left" Height="127" VerticalAlignment="Top" Width="299" Margin="0,0,-2,0">
<FlowDocument>
+24 -14
View File
@@ -33,6 +33,8 @@ namespace PWAPPv2
List<Source.DataObjects.PWImage> images;
string ConfigPath = "C:\\PWAPP\\Config\\Config.xml";
public MainWindow()
{
try
@@ -41,28 +43,37 @@ namespace PWAPPv2
}
catch (Exception)
{ }
try
{
images = new List<Source.DataObjects.PWImage>();
images = new List<Source.DataObjects.PWImage>();
apiconfig.LoadConfig(ConfigPath);
DataConfig = new Source.Database.DatabaseConfig(ConfigPath);
Source.Database.DatabaseConnection dbcon = new Source.Database.DatabaseConnection(DataConfig);
apiconfig.LoadConfig("./Config/Config.xml");
DataConfig = new Source.Database.DatabaseConfig("./Config/Config.xml");
Source.Database.DatabaseConnection dbcon = new Source.Database.DatabaseConnection(DataConfig);
apiCreds = new Source.DataObjects.APICredentials(apiconfig);
apiCreds = new Source.DataObjects.APICredentials(apiconfig);
apiConnection = new Source.API.APIConnection("http://apipatientweb.azurewebsites.net/",
apiCreds);
apiConnection = new Source.API.APIConnection("http://apipatientweb.azurewebsites.net/",
apiCreds);
InitializeComponent();
InitializeComponent();
PopulateComboBoxes();
PopulateComboBoxes();
patient = new Source.Patient();
patient = new Source.Patient();
patient.BuildFromDatabase(dbcon, args[0]);
patient.BuildFromDatabase(dbcon, args[0]);
this.DataContext = new Source.PatientGUIAdapter(patient);
this.DataContext = new Source.PatientGUIAdapter(patient);
}
catch(NullReferenceException)
{
}
catch(Exception e)
{
MessageBox.Show(e.Message);
}
}
private void PopulateComboBoxes()
@@ -244,7 +255,6 @@ namespace PWAPPv2
imageGrid.HorizontalAlignment = HorizontalAlignment.Left;
imageGrid.VerticalAlignment = VerticalAlignment.Top;
imageGrid.ShowGridLines = true;
imageGrid.Background = new SolidColorBrush(Colors.LightSteelBlue);
ColumnDefinition imageColumn = new ColumnDefinition();
imageColumn.Width = new GridLength(50);
+1 -1
View File
@@ -3,7 +3,7 @@ using System.Xml;
namespace PWAPPv2.Source
{
class APIConfig
public class APIConfig
{
public string PWUserID;
public string PWPassword;
+1 -34
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();
+6 -1
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;