Removed unnecessary XenConnection constructor which was there only to be used by the tests; used an object initialiser instead.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2018-01-19 16:44:26 +00:00 committed by Mihaela Stoica
parent c294e6514a
commit d83b91a987
3 changed files with 21 additions and 23 deletions

View File

@ -148,13 +148,18 @@ namespace XenAdminTests
return LoadDB(name, "root");
}
protected IXenConnection LoadDB(string name, string username)
private IXenConnection LoadDB(string name, string username)
{
string fileName = TestResource(name);
var connection = new XenConnection
{
Username = username,
Password = "",
Hostname = TestResource(name),
FriendlyName = name,
Port = 443,
SaveDisconnected = true
};
IXenConnection connection = new XenConnection(fileName, name);
connection.Username = username;
connection.Password = "";
lock (ConnectionsManager.ConnectionsLock)
{
ConnectionsManager.XenConnections.Add(connection);

View File

@ -158,12 +158,19 @@ namespace XenAdminTests
private void CreateNewConnection(string dbFileName, string username, string password)
{
string fileName = TestResource(dbFileName);
Assert.True(File.Exists(fileName), String.Format("Provided filename does not exist: '{0}'. " +
"If this is a new file, maybe the 'Copy To Ouput Directory' property has not been set",
fileName));
Assert.True(File.Exists(fileName),
String.Format("Provided filename does not exist: '{0}'. " +
"If this is a new file, maybe the 'Copy To Ouput Directory' property has not been set",
fileName));
XenAdminConfigManager.Provider = new TestXenAdminConfigProvider();
IXenConnection connection = new XenConnection(fileName, dbFileName);
var connection = new XenConnection
{
Hostname = fileName,
FriendlyName = dbFileName,
Port = 443,
SaveDisconnected = true
};
ServicePointManager.DefaultConnectionLimit = 20;
ServicePointManager.ServerCertificateValidationCallback = SSL.ValidateServerCertificate;

View File

@ -266,20 +266,6 @@ namespace XenAdmin.Network
cacheUpdateTimer = new System.Threading.Timer(cacheUpdater);
}
/// <summary>
/// Used by the automated tests. Initializes a new instance of the <see cref="XenConnection"/> class.
/// <param name="hostname"></param>
/// <param name="friendlyName"></param>
/// </summary>
public XenConnection(string hostname, string friendlyName)
: this()
{
this.Hostname = hostname;
this.FriendlyName = friendlyName;
this.Port = 443;
this.SaveDisconnected = true;
}
/// <summary>
/// For use by unit tests only.
/// </summary>