Created Unit Test Project
This commit is contained in:
parent
19153c9d02
commit
4a4bcc81e0
@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.33529.622
|
|||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PWAPPv2", "PWAPPv2\PWAPPv2.csproj", "{45E26AF8-41D7-4308-A2C8-D55A0350DB47}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PWAPPv2", "PWAPPv2\PWAPPv2.csproj", "{45E26AF8-41D7-4308-A2C8-D55A0350DB47}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{164B9220-F337-4E88-B619-0C52C502B9C4}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -15,6 +17,10 @@ Global
|
|||||||
{45E26AF8-41D7-4308-A2C8-D55A0350DB47}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{45E26AF8-41D7-4308-A2C8-D55A0350DB47}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{45E26AF8-41D7-4308-A2C8-D55A0350DB47}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{45E26AF8-41D7-4308-A2C8-D55A0350DB47}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{45E26AF8-41D7-4308-A2C8-D55A0350DB47}.Release|Any CPU.Build.0 = Release|Any CPU
|
{45E26AF8-41D7-4308-A2C8-D55A0350DB47}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{164B9220-F337-4E88-B619-0C52C502B9C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{164B9220-F337-4E88-B619-0C52C502B9C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{164B9220-F337-4E88-B619-0C52C502B9C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{164B9220-F337-4E88-B619-0C52C502B9C4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
<GroupBox Header="Refer To" HorizontalAlignment="Left" Height="55" Margin="0,120,0,0" VerticalAlignment="Top" Width="458" Grid.Column="1">
|
<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"/>
|
<ComboBox x:Name="boxReferTo" HorizontalAlignment="Left" Margin="0,10,-2,0" VerticalAlignment="Top" Width="448"/>
|
||||||
</GroupBox>
|
</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">
|
<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">
|
<RichTextBox x:Name="fieldRemakrs" HorizontalAlignment="Left" Height="127" VerticalAlignment="Top" Width="299" Margin="0,0,-2,0">
|
||||||
<FlowDocument>
|
<FlowDocument>
|
||||||
|
@ -33,6 +33,8 @@ namespace PWAPPv2
|
|||||||
|
|
||||||
List<Source.DataObjects.PWImage> images;
|
List<Source.DataObjects.PWImage> images;
|
||||||
|
|
||||||
|
string ConfigPath = "C:\\PWAPP\\Config\\Config.xml";
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -41,28 +43,37 @@ namespace PWAPPv2
|
|||||||
}
|
}
|
||||||
catch (Exception)
|
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");
|
apiCreds = new Source.DataObjects.APICredentials(apiconfig);
|
||||||
DataConfig = new Source.Database.DatabaseConfig("./Config/Config.xml");
|
|
||||||
Source.Database.DatabaseConnection dbcon = new Source.Database.DatabaseConnection(DataConfig);
|
|
||||||
|
|
||||||
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/",
|
InitializeComponent();
|
||||||
apiCreds);
|
|
||||||
|
|
||||||
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()
|
private void PopulateComboBoxes()
|
||||||
@ -244,7 +255,6 @@ namespace PWAPPv2
|
|||||||
imageGrid.HorizontalAlignment = HorizontalAlignment.Left;
|
imageGrid.HorizontalAlignment = HorizontalAlignment.Left;
|
||||||
imageGrid.VerticalAlignment = VerticalAlignment.Top;
|
imageGrid.VerticalAlignment = VerticalAlignment.Top;
|
||||||
imageGrid.ShowGridLines = true;
|
imageGrid.ShowGridLines = true;
|
||||||
imageGrid.Background = new SolidColorBrush(Colors.LightSteelBlue);
|
|
||||||
|
|
||||||
ColumnDefinition imageColumn = new ColumnDefinition();
|
ColumnDefinition imageColumn = new ColumnDefinition();
|
||||||
imageColumn.Width = new GridLength(50);
|
imageColumn.Width = new GridLength(50);
|
||||||
|
@ -3,7 +3,7 @@ using System.Xml;
|
|||||||
|
|
||||||
namespace PWAPPv2.Source
|
namespace PWAPPv2.Source
|
||||||
{
|
{
|
||||||
class APIConfig
|
public class APIConfig
|
||||||
{
|
{
|
||||||
public string PWUserID;
|
public string PWUserID;
|
||||||
public string PWPassword;
|
public string PWPassword;
|
||||||
|
@ -7,7 +7,7 @@ using System.Text;
|
|||||||
|
|
||||||
namespace PWAPPv2.Source.API
|
namespace PWAPPv2.Source.API
|
||||||
{
|
{
|
||||||
class APIConnection
|
public class APIConnection
|
||||||
{
|
{
|
||||||
private static string BaseURL;
|
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)
|
public string SendPostRequestAsync(string apiUri)
|
||||||
{
|
{
|
||||||
HttpClient client = new HttpClient();
|
HttpClient client = new HttpClient();
|
||||||
|
@ -1,12 +1,17 @@
|
|||||||
namespace PWAPPv2.Source.DataObjects
|
namespace PWAPPv2.Source.DataObjects
|
||||||
{
|
{
|
||||||
class APICredentials
|
public class APICredentials
|
||||||
{
|
{
|
||||||
public string UserID;
|
public string UserID;
|
||||||
public string Password;
|
public string Password;
|
||||||
public string PracticeId;
|
public string PracticeId;
|
||||||
public string APIid;
|
public string APIid;
|
||||||
|
|
||||||
|
public APICredentials()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public APICredentials(Source.APIConfig config)
|
public APICredentials(Source.APIConfig config)
|
||||||
{
|
{
|
||||||
UserID = config.PWUserID;
|
UserID = config.PWUserID;
|
||||||
|
20
UnitTests/Properties/AssemblyInfo.cs
Normal file
20
UnitTests/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
[assembly: AssemblyTitle("UnitTests")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("UnitTests")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
[assembly: Guid("164b9220-f337-4e88-b619-0c52c502b9c4")]
|
||||||
|
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
29
UnitTests/UnitTest1.cs
Normal file
29
UnitTests/UnitTest1.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using System;
|
||||||
|
using PWAPPv2.Source.API;
|
||||||
|
using PWAPPv2.Source.DataObjects;
|
||||||
|
|
||||||
|
// System.Threading.Tasks.Task<TResult>.Result.get returned "\"1|Endo|2|Implant|3|Oral Surgery|4|Ortho|5|Pedo|6|Perio|7|Restore|8|Other \\n\"" string
|
||||||
|
|
||||||
|
namespace UnitTests
|
||||||
|
{
|
||||||
|
[TestClass]
|
||||||
|
public class UnitTest1
|
||||||
|
{
|
||||||
|
[TestMethod]
|
||||||
|
public void TestV1Get()
|
||||||
|
{
|
||||||
|
APICredentials creds = new APICredentials();
|
||||||
|
creds.UserID = "testdoctor";
|
||||||
|
creds.Password = "testdoctor";
|
||||||
|
creds.PracticeId = "210";
|
||||||
|
creds.APIid = "12345678";
|
||||||
|
|
||||||
|
APIConnection conn = new APIConnection("http://apipatientweb.azurewebsites.net/", creds);
|
||||||
|
|
||||||
|
string res = conn.SendPostRequestAsync("api/PWReferralTypes");
|
||||||
|
Assert.AreEqual("\"1|Endo|2|Implant|3|Oral Surgery|4|Ortho|5|Pedo|6|Perio|7|Restore|8|Other \\n\"", res);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
74
UnitTests/UnitTests.csproj
Normal file
74
UnitTests/UnitTests.csproj
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props')" />
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{164B9220-F337-4E88-B619-0C52C502B9C4}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>UnitTests</RootNamespace>
|
||||||
|
<AssemblyName>UnitTests</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
|
||||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
|
||||||
|
<IsCodedUITest>False</IsCodedUITest>
|
||||||
|
<TestProjectType>UnitTest</TestProjectType>
|
||||||
|
<NuGetPackageImportStamp>
|
||||||
|
</NuGetPackageImportStamp>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="UnitTest1.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\PWAPPv2\PWAPPv2.csproj">
|
||||||
|
<Project>{45e26af8-41d7-4308-a2c8-d55a0350db47}</Project>
|
||||||
|
<Name>PWAPPv2</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props'))" />
|
||||||
|
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets'))" />
|
||||||
|
</Target>
|
||||||
|
<Import Project="..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets')" />
|
||||||
|
</Project>
|
5
UnitTests/packages.config
Normal file
5
UnitTests/packages.config
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="MSTest.TestAdapter" version="2.1.2" targetFramework="net472" />
|
||||||
|
<package id="MSTest.TestFramework" version="2.1.2" targetFramework="net472" />
|
||||||
|
</packages>
|
Loading…
x
Reference in New Issue
Block a user