コード例 #1
0
 /// <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;
     }
 }
コード例 #2
0
 public static void ClassCleanup()
 {
     if (null != smbClientStack)
     {
         smbClientStack.Dispose();
         smbClientStack = null;
     }
     PtfTestClassBase.Cleanup();
 }
コード例 #3
0
 /// <summary>
 /// default constructor. 
 /// </summary>
 internal SmbClientContext(SmbClient smbClient)
     : base()
 {
     this.smbClient = smbClient;
 }
コード例 #4
0
        /// <summary>
        /// This method is used to create the SMB client stack connection to get ready for further test.
        /// </summary>
        private void TestStarted()
        {
            this.addMidMark = (int)uint.MinValue;
            this.IsClosePacket = true;
            this.smbClientStack = new SmbClient();
            this.gmtTokens = new Dictionary<int, string>();
            IsQueryQuotaFirstResponse = true;
            this.openedFileName = string.Empty;

            // The server name or server IP address to connect to.
            string sutName = Site.Properties["SutMachineName"];

            // The port of server to connect to.
            int port = int.Parse(Site.Properties["SutPort"]);

            // The buffer size of transport.
            int bufferSize = int.Parse(Site.Properties["SmbTransportBufferSize"]);

            // The IP version to connect to server.
            IpVersion ipVersion = (IpVersion)Enum.Parse(
                typeof(IpVersion),
                Site.Properties["SmbTransportIpVersion"].ToString(),
                false);

            // To set up the TCP connection, and add the connection into context.
            // Exception will be thrown if failed to set up connection with server.
            this.smbClientStack.Connect(sutName, port, ipVersion, bufferSize);
        }
コード例 #5
0
 /// <summary>
 /// Close the files that are opened and disconnect the tree connection in the end of each test case.
 /// </summary>
 /// <param name="disposing">
 /// If disposing equals true, the method has been called directly or indirectly by a user's code. Managed and 
 /// unmanaged resources can be disposed. 
 /// If disposing equals false, the method has been called by the runtime inside the finalizer and only 
 /// unmanaged resources can be disposed.
 /// </param>
 protected override void Dispose(bool disposing)
 {
     if (this.smbClientStack != null)
     {
         this.smbClientStack.Dispose();
     }
     base.Dispose(disposing);
     this.smbClientStack = null;
 }
コード例 #6
0
        /// <summary>
        /// This method is called before each test case runs. User dose not need to call it directly.
        /// </summary>
        public override void Reset()
        {
            base.Reset();
            this.fId.Clear();
            this.sId.Clear();
            this.uId.Clear();
            this.tId.Clear();

            this.negReturnedCap = new Microsoft.Modeling.Set<Capabilities>();
            this.negResponseCap = new Microsoft.Modeling.Set<Capabilities>();
            this.createActionInternal = new Set<CreateAction>();
            // Disconnect the connection.
            if (this.smbClientStack != null)
            {
                this.smbClientStack.Disconnect();
                this.smbClientStack.Dispose();
                this.smbClientStack = null;
            }
        }
コード例 #7
0
 /// <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;
 }
コード例 #8
0
        /// <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;
            }
        }
コード例 #9
0
        /// <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;
            }
        }
コード例 #10
0
 /// <summary>
 /// Constructor
 /// </summary>
 public SmbClientTransport()
     : base()
 {
     internalTimeout = defaultTimeout;
     smbClient = new SmbClient();
 }