public static void ClassCleanup() { if (null != smbClientStack) { smbClientStack.Dispose(); smbClientStack = null; } PtfTestClassBase.Cleanup(); }
/// <summary> /// Use ClassCleanup to run code after a test case in a class have run. /// </summary> protected override void TestCleanup() { base.TestCleanup(); if (null != smbClientStack) { smbClientStack.Dispose(); smbClientStack = null; } }
public string[] GetLogicalDrives(string path) { using (var client = SmbClient.GetSmbClient(path)) { var shares = client.Client.ListShares(out var status); if (status != SMBLibrary.NTStatus.STATUS_SUCCESS) { throw new SmbIOException($"Failed to list shares: {status}", status); } return(shares.ToArray()); } }
/// <summary> /// Use TestInitialize to run code before running the test in the class. /// </summary> protected override void TestInitialize() { base.TestInitialize(); this.ISMBAdapterInstance = Site.GetAdapter <ISmbAdapter>(); this.IServerSetupAdapterInstance = Site.GetAdapter <IServerSetupAdapter>(); smbClientStack = new SmbClient(); serverName = Site.Properties["SutMachineName"]; serverPort = int.Parse(Site.Properties["SutPort"]); string ip = Site.Properties["SmbTransportIpVersion"]; switch (ip.ToLower()) { case "ipv4": ipVersion = IpVersion.Ipv4; break; case "ipv6": ipVersion = IpVersion.Ipv6; break; default: ipVersion = IpVersion.Any; break; } bufferSize = int.Parse(Site.Properties["SmbTransportBufferSize"]); domainName = Site.Properties["SutLoginDomain"]; userName = Site.Properties["SutLoginAdminUserName"]; password = Site.Properties["SutLoginAdminPwd"]; string ptfSutOs = Site.Properties["SutPlatformOS"].ToString(); if (Enum.Parse(typeof(Platform), ptfSutOs, true) != null) { sutOsVersion = (Platform)Enum.Parse(typeof(Platform), ptfSutOs, true); } else { sutOsVersion = Platform.NonWindows; } }
/// <summary> /// Release resources. /// </summary> /// <param name="disposing">If disposing equals true, Managed and unmanaged resources are disposed. /// if false, Only unmanaged resources can be disposed.</param> protected override void Dispose(bool disposing) { if (!this.disposed) { // If disposing equals true, dispose all managed and unmanaged resources. if (disposing) { // Free managed resources & other reference types: } // Call the appropriate methods to clean up unmanaged resources. if (this.smbClient != null) { this.smbClient.Dispose(); this.smbClient = null; } base.Dispose(disposing); this.disposed = true; } }
/// <summary> /// default constructor. /// </summary> internal SmbClientContext(SmbClient smbClient) : base() { this.smbClient = smbClient; }
/// <summary> /// default constructor. /// </summary> /// <param name = "smbClient"> /// the smbclient contains context for decoder. to update the states of sdk. /// </param> public SmbClientDecodePacket(SmbClient smbClient) : base(smbClient.Context, new CifsClientConfig()) { this.smbClient = smbClient; }
/// <summary> /// Constructor /// </summary> public SmbClientTransport() : base() { internalTimeout = defaultTimeout; smbClient = new SmbClient(); }