Refactor to api connections. Update Checker.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using PWAPPv2.Source;
|
||||
|
||||
namespace UnitTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ConfigTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestGetPracticeConfigs()
|
||||
{
|
||||
PWAPPv2.Source.Config.Configuration configuration = new PWAPPv2.Source.Config.Configuration(".\\Config\\PracticeConfig.xml");
|
||||
Assert.IsNotNull(configuration);
|
||||
|
||||
string apiKey = configuration.Get("pwapiid");
|
||||
Assert.IsNotNull(apiKey);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
|
||||
namespace UnitTests
|
||||
{
|
||||
[TestClass]
|
||||
public class PWConnectionTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestCheckUpdate()
|
||||
{
|
||||
PWAPPv2.Source.Config.Configuration practiceConfig = new PWAPPv2.Source.Config.Configuration(".\\Config\\PracticeConfig.xml");
|
||||
PWAPPv2.Source.Config.Configuration universalConfig = new PWAPPv2.Source.Config.Configuration(".\\Config\\UniversalConfig.xml");
|
||||
|
||||
PWAPPv2.Source.API.PWApiConnection pwApiConnection = new PWAPPv2.Source.API.PWApiConnection(practiceConfig, universalConfig);
|
||||
Assert.IsNotNull(pwApiConnection);
|
||||
|
||||
|
||||
Assert.IsFalse(pwApiConnection.CheckForUpdate());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,5 +25,35 @@ namespace UnitTests
|
||||
Assert.AreEqual("\"1|Endo|2|Implant|3|Oral Surgery|4|Ortho|5|Pedo|6|Perio|7|Restore|8|Other \\n\"", res);
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestV2Get()
|
||||
{
|
||||
APICredentials creds = new APICredentials();
|
||||
creds.UserID = "testdoctor";
|
||||
creds.Password = "testdoctor";
|
||||
creds.PracticeId = "210";
|
||||
creds.APIid = "12345678";
|
||||
|
||||
APIConnection conn = new APIConnection("https://localhost:44354/", creds);
|
||||
string res = conn.SendPostWithCredsInHeader("api/PWAppVersion", "");
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(RequestFailedExcpetion))]
|
||||
public void TestInvalidCredentialsV2()
|
||||
{
|
||||
APICredentials creds = new APICredentials();
|
||||
creds.UserID = "testdoctor";
|
||||
creds.Password = "badPassword";
|
||||
creds.PracticeId = "210";
|
||||
creds.APIid = "12345678";
|
||||
|
||||
APIConnection conn = new APIConnection("https://localhost:44354/", creds);
|
||||
string res = conn.SendPostWithCredsInHeader("api/PWAppVersion", "");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="UnitTest1.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ConfigTest.cs" />
|
||||
<Compile Include="PWConnectionTest.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
||||
Reference in New Issue
Block a user