diff --git a/MCC_UnitTest/TestSuite.cs b/MCC_UnitTest/TestSuite.cs
index c6a900e..e733072 100644
--- a/MCC_UnitTest/TestSuite.cs
+++ b/MCC_UnitTest/TestSuite.cs
@@ -10,6 +10,8 @@ namespace MCC_UnitTest
[TestClass]
public class TestSuite
{
+
+ #region area oggetti globali
///
/// Token x cancellazione thread
///
@@ -27,35 +29,41 @@ namespace MCC_UnitTest
///
protected string confFilePath = "mconnect.conf.yaml";
+ [TestInitialize]
+ public void Initialize()
+ {
+ // arrange
+ if (_cts != null)
+ {
+ _cts.Cancel();
+ }
+
+ // act (COMMON)
+ MCC = new MConnectClient();
+ }
+
+ [TestCleanup]
+ public void Cleanup()
+ {
+ MCC = null;
+ }
+
+
+ #endregion
+
#region BASE ed INIT
[TestMethod]
[Timeout(5000)] // Milliseconds
public void Test_Create_MCC()
{
- // arrange
- if (_cts != null)
- {
- _cts.Cancel();
- }
-
- // act
- MCC = new MConnectClient();
-
// assert
Assert.IsNotNull(MCC);
}
[TestMethod]
public void Test_initSDK_hasResult()
{
- // arrange
- if (_cts != null)
- {
- _cts.Cancel();
- }
-
// act
- MCC = new MConnectClient();
Task taskResult = MCC.InitSDKAsync(confFilePath, CancellationToken.None);
// assert
@@ -64,138 +72,24 @@ namespace MCC_UnitTest
[TestMethod]
public void Test_initSDK_throwNoConfig()
{
- // arrange
- if (_cts != null)
- {
- _cts.Cancel();
- }
-
// act
- MCC = new MConnectClient();
Task taskResult = MCC.InitSDKAsync("", CancellationToken.None);
// assert is handled by the ExpectedException
}
[TestMethod]
- public void Test_initSDK_callResultOk()
+ public void Test_initSDK_allPropertyOk()
{
- // arrange
- if (_cts != null)
- {
- _cts.Cancel();
- }
-
// act
- MCC = new MConnectClient();
Task taskResult = MCC.InitSDKAsync(confFilePath, CancellationToken.None);
reqStatus = taskResult.Result;
- // assert
+ // asserts
Assert.IsTrue(reqStatus.CallResultOk);
- }
- [TestMethod]
- public void Test_initSDK_errorNull()
- {
- // arrange
- if (_cts != null)
- {
- _cts.Cancel();
- }
-
- // act
- MCC = new MConnectClient();
-
- // init async...
- Task taskResult = MCC.InitSDKAsync(confFilePath, CancellationToken.None);
-
- // converto il risultato restituito...
- reqStatus = taskResult.Result;
-
- // assert
Assert.IsNull(reqStatus.Error);
- }
- [TestMethod]
- public void Test_initSDK_localOk()
- {
- // arrange
- if (_cts != null)
- {
- _cts.Cancel();
- }
-
- // act
- MCC = new MConnectClient();
-
- // init async...
- Task taskResult = MCC.InitSDKAsync(confFilePath, CancellationToken.None);
-
- // converto il risultato restituito...
- reqStatus = taskResult.Result;
-
- // assert
Assert.IsTrue(reqStatus.LocalStatusOk);
- }
- [TestMethod]
- public void Test_initSDK_cloudOk()
- {
- // arrange
- if (_cts != null)
- {
- _cts.Cancel();
- }
-
- // act
- MCC = new MConnectClient();
-
- // init async...
- Task taskResult = MCC.InitSDKAsync(confFilePath, CancellationToken.None);
-
- // converto il risultato restituito...
- reqStatus = taskResult.Result;
-
- // assert
Assert.IsTrue(reqStatus.CloudStatusOk);
- }
- [TestMethod]
- public void Test_initSDK_sourceNotNull()
- {
- // arrange
- if (_cts != null)
- {
- _cts.Cancel();
- }
-
- // act
- MCC = new MConnectClient();
-
- // init async...
- Task taskResult = MCC.InitSDKAsync(confFilePath, CancellationToken.None);
-
- // converto il risultato restituito...
- reqStatus = taskResult.Result;
-
- // assert
Assert.IsNotNull(reqStatus.Source);
- }
- [TestMethod]
- public void Test_initSDK_payloadIsNull()
- {
- // arrange
- if (_cts != null)
- {
- _cts.Cancel();
- }
-
- // act
- MCC = new MConnectClient();
-
- // init async...
- Task taskResult = MCC.InitSDKAsync(confFilePath, CancellationToken.None);
-
- // converto il risultato restituito...
- reqStatus = taskResult.Result;
-
- // assert
Assert.IsNull(reqStatus.Payload);
}