-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAssemblyInitializeClass.cs
69 lines (62 loc) · 2.21 KB
/
AssemblyInitializeClass.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//___________________________________________________________________________________
//
// Copyright (C) 2020, Mariusz Postol LODZ POLAND.
//
// To be in touch join the community at GITTER: https://gitter.im/mpostol/OPC-UA-OOI
//___________________________________________________________________________________
using CAS.CommServer.ProtocolHub.Communication;
using CAS.CommServer.ProtocolHub.MonitorInterface;
using CAS.Lib.CodeProtect;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Diagnostics;
using System.IO;
namespace CAS.CommServer.ProtocolHub.CommunicationUnitTests
{
[TestClass()]
[DeploymentItem("CAS.License.lic")]
[DeploymentItem("DefaultConfig.xml")]
public class AssemblyInitializeClass
{
internal static CommServerComponent CommServerComponent { get; private set; }
private static string m_InstallLicenseError = string.Empty;
[AssemblyInitialize()]
public static void InstallLicense(TestContext testContext)
{
try
{
LibInstaller.InstallLicense(false);
CommServerComponent = new CommServerComponent();
SettingsBaseFixture _settings = new SettingsBaseFixture();
CommServerComponent.Initialize("DefaultConfig.xml", _settings);
}
catch (System.Exception _ex)
{
m_InstallLicenseError = _ex.ToString();
Debug.WriteLine(m_InstallLicenseError);
throw;
}
}
[AssemblyCleanup()]
public static void MyClassTestCleanup()
{
CommServerComponent.Dispose();
}
[TestMethod]
public void LicenseExist()
{
FileInfo _licenseFile = new FileInfo("DefaultConfig.xml");
Assert.IsTrue(_licenseFile.Exists, "DefaultConfig.xml doesn't exist in the working directory");
}
[TestMethod]
public void AssemblyInitializeTestMethod()
{
Assert.IsTrue(string.IsNullOrEmpty(m_InstallLicenseError), m_InstallLicenseError);
}
#region instrumentation
private class SettingsBaseFixture : ISettingsBase
{
public object this[string propertyName] { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); }
}
#endregion
}
}