IsCurrentVersionIncreased() public static method

Check whether the current version was increased.
public static IsCurrentVersionIncreased ( string oldVersion, string currentVersion ) : bool
oldVersion string The old version.
currentVersion string The current version.
return bool
        /// <summary>
        /// A common method used to verify that the client uses the RestoreVersion operation to successfully restore
        /// the file specified by a URL to a specific version when check out is enforced.
        /// </summary>
        /// <param name="url">The URL of a file.</param>
        private void RestoreVersionVerification(string url)
        {
            // Enable the versioning of the list.
            bool setVersioning = this.sutControlAdapterInstance.SetVersioning(this.documentLibrary, true, true);

            Site.Assert.IsTrue(
                setVersioning,
                "SetVersioning operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                setVersioning);

            // Upload the file into specific list.
            bool isAddFileSuccessful = this.sutControlAdapterInstance.AddFile(this.documentLibrary, this.fileName, TestSuiteHelper.UploadFileName);

            Site.Assert.IsTrue(
                isAddFileSuccessful,
                "AddFile operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                isAddFileSuccessful);

            // Check out and check in file one time to create a new version of the file.
            this.testSuiteHelper.AddOneFileVersion(this.fileName);

            // Enforce the file to be checked out.
            bool setServerEnforceCheckOut = this.sutControlAdapterInstance.SetEnforceCheckout(this.documentLibrary, true);

            Site.Assert.IsTrue(
                setServerEnforceCheckOut,
                "SetServerEnforceCheckOut operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                setServerEnforceCheckOut);

            // Call GetVersions operation using relative fileName.
            GetVersionsResponseGetVersionsResult getVersionsResponse = this.protocolAdapterInstance.GetVersions(
                url);

            // Verify the GetVersions results.
            this.testSuiteHelper.VerifyResultsInformation(getVersionsResponse.results, OperationName.GetVersions, true);

            // Check out the specified file.
            bool isCheckOutFile = this.listsSutControlAdaterInstance.CheckoutFile(this.fileAbsoluteUrl);

            Site.Assert.IsTrue(
                isCheckOutFile,
                "CheckOutFile operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                isCheckOutFile);

            // Get the current version of the file.
            string currentVersionBeforeRestore = AdapterHelper.GetCurrentVersion(getVersionsResponse.results.result);

            // Get the previous version which is specific to be restored.
            string restoreVersion = AdapterHelper.GetPreviousVersion(getVersionsResponse.results.result);

            // Call RestoreVersion operation using relative fileName and restore a specified file to a specific version.
            RestoreVersionResponseRestoreVersionResult restoreVersionReponse = this.protocolAdapterInstance.RestoreVersion(
                url, restoreVersion);

            // Check in the specified file.
            bool isCheckInFile = this.listsSutControlAdaterInstance.CheckInFile(
                this.fileAbsoluteUrl,
                TestSuiteHelper.FileComments,
                ((int)VersionType.MinorCheckIn).ToString());

            Site.Assert.IsTrue(
                isCheckInFile,
                "CheckInFile operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                isCheckInFile);

            // Verify the RestoreVersion results.
            this.testSuiteHelper.VerifyResultsInformation(restoreVersionReponse.results, OperationName.RestoreVersion, true);

            // Get the current version in RestoreVersion response.
            string currentVersionAfterRestore = AdapterHelper.GetCurrentVersion(restoreVersionReponse.results.result);

            // Verify whether the current version was increased by RestoreVersion.
            bool isCurrentVersionIncreased = AdapterHelper.IsCurrentVersionIncreased(
                currentVersionBeforeRestore,
                currentVersionAfterRestore);

            // Add the debug information
            Site.Log.Add(
                LogEntryKind.Debug,
                "Verify MS-VERSS_R182, the current version before RestoreVersion is {0}, and after RestoreVersion is {1}",
                currentVersionBeforeRestore,
                currentVersionAfterRestore);

            // Verify MS-VERSS requirement: MS-VERSS_R182
            Site.CaptureRequirementIfIsTrue(
                isCurrentVersionIncreased,
                182,
                @"[In RestoreVersion] After the restoration, the current version number of the file MUST still be increased, as with any other change.");
        }
        public void MSVERSS_S02_TC03_RestoreVersionWithoutEnforceCheckout()
        {
            // Enable the versioning of the list.
            bool setVersioning = this.sutControlAdapterInstance.SetVersioning(this.documentLibrary, true, true);

            Site.Assert.IsTrue(
                setVersioning,
                "SetVersioning operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                setVersioning);

            // Protocol server does not enforce that only checked out files can be modified.
            bool isSetServerEnforceCheckOut = this.sutControlAdapterInstance.SetEnforceCheckout(this.documentLibrary, false);

            Site.Assert.IsTrue(
                isSetServerEnforceCheckOut,
                "SetServerEnforceCheckOut operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                isSetServerEnforceCheckOut);

            // Upload the first file into specific list.
            bool isAddFileSuccessful = this.sutControlAdapterInstance.AddFile(this.documentLibrary, this.fileName, TestSuiteHelper.UploadFileName);

            Site.Assert.IsTrue(
                isAddFileSuccessful,
                "AddFile operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                isAddFileSuccessful);

            // Check out and check in first file to add the file versions.
            this.testSuiteHelper.AddOneFileVersion(this.fileName);

            // Call GetVersions operation using absolute fileName.
            GetVersionsResponseGetVersionsResult getVersionsResponse = this.protocolAdapterInstance.GetVersions(this.fileAbsoluteUrl.AbsoluteUri);

            // Verify the GetVersions results.
            this.testSuiteHelper.VerifyResultsInformation(getVersionsResponse.results, OperationName.GetVersions, true);

            // Get the current version.
            string currentVersionBeforeRestore = AdapterHelper.GetCurrentVersion(getVersionsResponse.results.result);

            // Get the previous version which is specific to be restored.
            string restoreVersion = AdapterHelper.GetPreviousVersion(getVersionsResponse.results.result);

            // Call RestoreVersion operation using absolute fileName and restore a specified file to a specific version.
            RestoreVersionResponseRestoreVersionResult restoreVersionNotCheckOutResponse =
                this.protocolAdapterInstance.RestoreVersion(this.fileAbsoluteUrl.AbsoluteUri, restoreVersion);

            // Verify the RestoreVersion results.
            this.testSuiteHelper.VerifyResultsInformation(restoreVersionNotCheckOutResponse.results, OperationName.RestoreVersion, true);

            // Get the current version in RestoreVersion response.
            string currentVersionAfterNotCheckOutRestore = AdapterHelper.GetCurrentVersion(
                restoreVersionNotCheckOutResponse.results.result);

            // Verify whether the current version after RestoreVersion is increased when the file is not checked out.
            bool isCurrentVersionIncreased = AdapterHelper.IsCurrentVersionIncreased(
                currentVersionBeforeRestore,
                currentVersionAfterNotCheckOutRestore);

            // Add the debug information
            Site.Log.Add(
                LogEntryKind.Debug,
                "Verify MS-VERSS_R185, if the file is not checked out, the current version before RestoreVersion is {0}," +
                " and after RestoreVersion is {1}",
                currentVersionBeforeRestore,
                currentVersionAfterNotCheckOutRestore);

            // Verify MS-VERSS requirement: MS-VERSS_R185
            Site.CaptureRequirementIfIsTrue(
                isCurrentVersionIncreased,
                185,
                @"[In RestoreVersion] If the file is not checked out before the restoration, the current version number of the file MUST still be increased, as with any other change.");

            // Check out the file.
            bool isCheckOutFile = this.listsSutControlAdaterInstance.CheckoutFile(this.fileAbsoluteUrl);

            Site.Assert.IsTrue(
                isCheckOutFile,
                "CheckOutFile operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                isCheckOutFile);

            // Call GetVersions operation using absolute fileName.
            getVersionsResponse = this.protocolAdapterInstance.GetVersions(this.fileAbsoluteUrl.AbsoluteUri);

            // Get current version before RestoreVersion operation in GetVersions response.
            currentVersionBeforeRestore = AdapterHelper.GetCurrentVersion(getVersionsResponse.results.result);

            // Get the previous version which is specific to be restored.
            restoreVersion = AdapterHelper.GetPreviousVersion(getVersionsResponse.results.result);

            // Call RestoreVersion operation using absolute fileName and restore a specified file to a specific version.
            RestoreVersionResponseRestoreVersionResult restoreVersionIsCheckOutResponse =
                this.protocolAdapterInstance.RestoreVersion(this.fileAbsoluteUrl.AbsoluteUri, restoreVersion);

            // Get the current version in RestoreVersion response.
            string currentVersionAfterIsCheckOutRestore = AdapterHelper.GetCurrentVersion(
                restoreVersionIsCheckOutResponse.results.result);

            // Add the debug information
            Site.Log.Add(
                LogEntryKind.Debug,
                "Verify MS-VERSS_R186, if the file is checked out, the current version before RestoreVersion is {0}," +
                " and after RestoreVersion is {1}",
                currentVersionBeforeRestore,
                currentVersionAfterIsCheckOutRestore);

            // Verify MS-VERSS requirement: MS-VERSS_R186
            Site.CaptureRequirementIfAreEqual <string>(
                currentVersionBeforeRestore,
                currentVersionAfterIsCheckOutRestore,
                186,
                @"[In RestoreVersion] If the file is checked out, the current version number of the file after restoration MUST remain the same as before restoration.");

            // Check in file.
            bool isCheckInFile = this.listsSutControlAdaterInstance.CheckInFile(
                this.fileAbsoluteUrl,
                TestSuiteHelper.FileComments,
                ((int)VersionType.MinorCheckIn).ToString());

            Site.Assert.IsTrue(
                isCheckInFile,
                "CheckInFile operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                isCheckInFile);
        }