public void BVT_EnumerateSnapShots() { #region Check Applicability TestConfig.CheckIOCTL(CtlCode_Values.FSCTL_SRV_ENUMERATE_SNAPSHOTS); #endregion uint treeId; FILEID fileId; OpenFile(out treeId, out fileId); BaseTestSite.Log.Add( LogEntryKind.TestStep, "Enumerate snapshots by sending the first IOCTL request: FSCTL_SRV_ENUMERATE_SNAPSHOTS, with MaxOutputResponse set to 16."); SRV_SNAPSHOT_ARRAY snapShotArray; client.EnumerateSnapShots( treeId, fileId, SizeOfEmptySnapShotArray, out snapShotArray, checker: (Packet_Header header, IOCTL_Response response) => { BaseTestSite.Assert.AreEqual( Smb2Status.STATUS_SUCCESS, header.Status, "FSCTL_SRV_ENUMERATE_SNAPSHOTS should succeed, actually server returns {0}.", Smb2Status.GetStatusCode(header.Status)); }); BaseTestSite.Log.Add( LogEntryKind.TestStep, "Verify SRV_SNAPSHOT_ARRAY returned in response."); BaseTestSite.Assert.AreEqual( TestConfig.NumberOfPreviousVersions, snapShotArray.NumberOfSnapShots, "NumberOfSnapShots should be {0}.", TestConfig.NumberOfPreviousVersions); BaseTestSite.Assert.AreEqual( (uint)0, snapShotArray.NumberOfSnapShotsReturned, "NumberOfSnapShotsReturned should be 0."); BaseTestSite.Log.Add( LogEntryKind.TestStep, "Enumerate snapshots by sending the second IOCTL request: FSCTL_SRV_ENUMERATE_SNAPSHOTS, with MaxOutputResponse set to 65536."); client.EnumerateSnapShots( treeId, fileId, Smb2FunctionalClient.DefaultMaxOutputResponse, out snapShotArray, checker: (Packet_Header header, IOCTL_Response response) => { BaseTestSite.Assert.AreEqual( Smb2Status.STATUS_SUCCESS, header.Status, "FSCTL_SRV_ENUMERATE_SNAPSHOTS should succeed, actually server returns {0}.", Smb2Status.GetStatusCode(header.Status)); }); BaseTestSite.Log.Add( LogEntryKind.TestStep, "Verify SRV_SNAPSHOT_ARRAY returned in response."); BaseTestSite.Assert.AreEqual( TestConfig.NumberOfPreviousVersions, snapShotArray.NumberOfSnapShots, "NumberOfSnapShots should be {0}.", TestConfig.NumberOfPreviousVersions); BaseTestSite.Log.Add(LogEntryKind.Debug, "NumberOfSnapShotsReturned is {0}.", snapShotArray.NumberOfSnapShotsReturned); string[] versionArray = System.Text.Encoding.Unicode.GetString(snapShotArray.SnapShots).Split('\0'); BaseTestSite.Assert.AreEqual( snapShotArray.NumberOfSnapShotsReturned + 2, (uint)versionArray.Length, "The field \"SnapShots\" should be separated by UNICODE null characters and terminated by two UNICODE null characters."); DateTime dt; for (int i = 0; i < snapShotArray.NumberOfSnapShotsReturned; ++i) { BaseTestSite.Assert.IsTrue( DateTime.TryParseExact(versionArray[i], "@GMT-yyyy.MM.dd-HH.mm.ss", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dt), "This SnapShot is {0}. The format of each SnapShot should be \"@GMT-YYYY.MM.DD-HH.MM.SS\". ", versionArray[i]); } BaseTestSite.Log.Add(LogEntryKind.TestStep, "Tear down client by sending the following requests: CLOSE; TREE_DISCONNECT; LOG_OFF"); client.Close(treeId, fileId); client.TreeDisconnect(treeId); client.LogOff(); }