SonarLint.VisualStudio.Integration.Service.ConnectionInformation.Dispose C# (CSharp) Method

Dispose() public method

public Dispose ( ) : void
return void
        public void Dispose()
        {
            // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
            this.Dispose(true);
        }
        #endregion

Same methods

ConnectionInformation::Dispose ( bool disposing ) : void

Usage Example

        public void ConnectionInformation_WithLoginInformation()
        {
            // Setup
            var userName = "******";
            var passwordUnsecure = "admin";
            var password = passwordUnsecure.ConvertToSecureString();
            var serverUri = new Uri("http://localhost/");
            var testSubject = new ConnectionInformation(serverUri, userName, password);

            // Act
            password.Dispose(); // Connection information should maintain it's own copy of the password

            // Verify
            Assert.AreEqual(passwordUnsecure, testSubject.Password.ConvertToUnsecureString(), "Password doesn't match");
            Assert.AreEqual(userName, testSubject.UserName, "UserName doesn't match");
            Assert.AreEqual(serverUri, testSubject.ServerUri, "ServerUri doesn't match");

            // Act clone
            var testSubject2 = (ConnectionInformation)((ICloneable)testSubject).Clone();

            // Now dispose the test subject
            testSubject.Dispose();

            // Verify testSubject
            Exceptions.Expect<ObjectDisposedException>(() => testSubject.Password.ConvertToUnsecureString());

            // Verify testSubject2
            Assert.AreEqual(passwordUnsecure, testSubject2.Password.ConvertToUnsecureString(), "Password doesn't match");
            Assert.AreEqual(userName, testSubject2.UserName, "UserName doesn't match");
            Assert.AreEqual(serverUri, testSubject2.ServerUri, "ServerUri doesn't match");
        }