public byte[] RetrieveContentData(string filename)
        {
            switch (testConfig.ContentTransport)
            {
            case ContentInformationTransport.PCCRTP:

                PccrtpClient  pccrtpClient  = new PccrtpClient();
                PccrtpRequest pccrtpRequest = pccrtpClient.CreatePccrtpRequest(
                    testConfig.ContentServerComputerName,
                    testConfig.ContentServerHTTPListenPort,
                    filename);

                PccrtpResponse pccrtpResponse = pccrtpClient.SendHttpRequest(
                    Microsoft.Protocols.TestTools.StackSdk.BranchCache.Pccrtp.HttpVersionType.HttpVersion11,
                    pccrtpRequest,
                    (int)testConfig.Timeout.TotalMilliseconds);

                testSite.Assert.AreNotEqual(
                    "peerdist",
                    pccrtpResponse.HttpResponse.ContentEncoding,
                    "The content server should not have content information ready yet");

                return(pccrtpResponse.PayloadData);

            case ContentInformationTransport.SMB2:

                using (BranchCacheSmb2ClientTransport smb2Client = new BranchCacheSmb2ClientTransport(testConfig.Timeout, testSite, testConfig.SupportBranchCacheV1, testConfig.SupportBranchCacheV2))
                {
                    smb2Client.OpenFile(
                        testConfig.ContentServerComputerName,
                        testConfig.SharedFolderName,
                        filename,
                        testConfig.SecurityPackageType,
                        testConfig.DomainName,
                        testConfig.UserName,
                        testConfig.UserPassword,
                        AccessMask.GENERIC_READ);

                    HASH_HEADER hashHeader;
                    byte[]      hashData = null;

                    uint status = 0;

                    if (testConfig.SupportBranchCacheV1)
                    {
                        status = smb2Client.ReadHash(
                            SRV_READ_HASH_Request_HashType_Values.SRV_HASH_TYPE_PEER_DIST,
                            SRV_READ_HASH_Request_HashVersion_Values.SRV_HASH_VER_1,
                            SRV_READ_HASH_Request_HashRetrievalType_Values.SRV_HASH_RETRIEVE_HASH_BASED,
                            0,
                            uint.MaxValue,
                            out hashHeader,
                            out hashData);

                        testSite.Assert.AreNotEqual(
                            Smb2Status.STATUS_SUCCESS,
                            status,
                            "The content server should not have content information ready yet");

                        testSite.CaptureRequirementIfAreEqual(
                            Smb2Status.STATUS_HASH_NOT_PRESENT,
                            status,
                            RequirementCategory.HashNotPresent,
                            RequirementCategory.HashNotPresentMessage);
                    }

                    if (testConfig.SupportBranchCacheV2)
                    {
                        status = smb2Client.ReadHash(
                            SRV_READ_HASH_Request_HashType_Values.SRV_HASH_TYPE_PEER_DIST,
                            SRV_READ_HASH_Request_HashVersion_Values.SRV_HASH_VER_2,
                            SRV_READ_HASH_Request_HashRetrievalType_Values.SRV_HASH_RETRIEVE_FILE_BASED,
                            0,
                            uint.MaxValue,
                            out hashHeader,
                            out hashData);

                        testSite.Assert.AreNotEqual(
                            Smb2Status.STATUS_SUCCESS,
                            status,
                            "The content server should not have content information ready yet");

                        testSite.CaptureRequirementIfAreEqual(
                            Smb2Status.STATUS_HASH_NOT_PRESENT,
                            status,
                            RequirementCategory.HashNotPresent,
                            RequirementCategory.HashNotPresentMessage);
                    }

                    return(smb2Client.ReadAllBytes());
                }

            default:
                throw new NotImplementedException();
            }
        }
        public byte[] RetrieveContentInformation(BranchCacheVersion version, string filename)
        {
            switch (testConfig.ContentTransport)
            {
                case ContentInformationTransport.PCCRTP:

                    TestUtility.DoUntilSucceed(() => sutControlAdapter.IsHTTPHashExisted(testConfig.ContentServerComputerName), testConfig.Timeout, testConfig.RetryInterval);

                    PccrtpClient pccrtpClient = new PccrtpClient();
                    PccrtpRequest pccrtpRequest = pccrtpClient.CreatePccrtpRequest(
                        testConfig.ContentServerComputerName,
                        testConfig.ContentServerHTTPListenPort,
                        filename,
                        version);

                    var pccrtpResponse = pccrtpClient.SendHttpRequest(
                        Microsoft.Protocols.TestTools.StackSdk.BranchCache.Pccrtp.HttpVersionType.HttpVersion11,
                        pccrtpRequest,
                        (int)testConfig.Timeout.TotalMilliseconds);

                    testSite.Assert.AreEqual(
                       "peerdist",
                       pccrtpResponse.HttpResponse.ContentEncoding,
                       "The content server should return peerdist encoded content information");

                    return pccrtpResponse.PayloadData;

                case ContentInformationTransport.SMB2:

                    using (BranchCacheSmb2ClientTransport smb2Client = new BranchCacheSmb2ClientTransport(testConfig.Timeout, testSite, testConfig.SupportBranchCacheV1, testConfig.SupportBranchCacheV2))
                    {
                        smb2Client.OpenFile(
                            testConfig.ContentServerComputerName,
                            testConfig.SharedFolderName,
                            filename,
                            testConfig.SecurityPackageType,
                            testConfig.DomainName,
                            testConfig.UserName,
                            testConfig.UserPassword,
                            AccessMask.GENERIC_READ);

                        HASH_HEADER hashHeader;
                        byte[] hashData = null;

                        TestUtility.DoUntilSucceed(
                            () => smb2Client.ReadHash(
                                SRV_READ_HASH_Request_HashType_Values.SRV_HASH_TYPE_PEER_DIST,
                                version == BranchCacheVersion.V1 ? SRV_READ_HASH_Request_HashVersion_Values.SRV_HASH_VER_1 : SRV_READ_HASH_Request_HashVersion_Values.SRV_HASH_VER_2,
                                version == BranchCacheVersion.V1 ? SRV_READ_HASH_Request_HashRetrievalType_Values.SRV_HASH_RETRIEVE_HASH_BASED : SRV_READ_HASH_Request_HashRetrievalType_Values.SRV_HASH_RETRIEVE_FILE_BASED,
                                0,
                                uint.MaxValue,
                                out hashHeader,
                                out hashData) == Smb2Status.STATUS_SUCCESS,
                            testConfig.Timeout,
                            testConfig.RetryInterval);

                        testSite.Assert.AreNotEqual(
                           0,
                           hashData.Length,
                           "The content server should return content information in READ_HASH_RESPONSE");

                        return hashData;
                    }

                default:
                    throw new NotImplementedException();
            }
        }
        public byte[] RetrieveContentInformation(BranchCacheVersion version, string filename)
        {
            switch (testConfig.ContentTransport)
            {
            case ContentInformationTransport.PCCRTP:

                TestUtility.DoUntilSucceed(() => sutControlAdapter.IsHTTPHashExisted(testConfig.ContentServerComputerName), testConfig.Timeout, testConfig.RetryInterval);

                PccrtpClient  pccrtpClient  = new PccrtpClient();
                PccrtpRequest pccrtpRequest = pccrtpClient.CreatePccrtpRequest(
                    testConfig.ContentServerComputerName,
                    testConfig.ContentServerHTTPListenPort,
                    filename,
                    version);

                var pccrtpResponse = pccrtpClient.SendHttpRequest(
                    Microsoft.Protocols.TestTools.StackSdk.BranchCache.Pccrtp.HttpVersionType.HttpVersion11,
                    pccrtpRequest,
                    (int)testConfig.Timeout.TotalMilliseconds);

                testSite.Assert.AreEqual(
                    "peerdist",
                    pccrtpResponse.HttpResponse.ContentEncoding,
                    "The content server should return peerdist encoded content information");

                return(pccrtpResponse.PayloadData);

            case ContentInformationTransport.SMB2:

                using (BranchCacheSmb2ClientTransport smb2Client = new BranchCacheSmb2ClientTransport(testConfig.Timeout, testSite, testConfig.SupportBranchCacheV1, testConfig.SupportBranchCacheV2))
                {
                    smb2Client.OpenFile(
                        testConfig.ContentServerComputerName,
                        testConfig.SharedFolderName,
                        filename,
                        testConfig.SecurityPackageType,
                        testConfig.DomainName,
                        testConfig.UserName,
                        testConfig.UserPassword,
                        AccessMask.GENERIC_READ);

                    HASH_HEADER hashHeader;
                    byte[]      hashData = null;

                    TestUtility.DoUntilSucceed(
                        () => smb2Client.ReadHash(
                            SRV_READ_HASH_Request_HashType_Values.SRV_HASH_TYPE_PEER_DIST,
                            version == BranchCacheVersion.V1 ? SRV_READ_HASH_Request_HashVersion_Values.SRV_HASH_VER_1 : SRV_READ_HASH_Request_HashVersion_Values.SRV_HASH_VER_2,
                            version == BranchCacheVersion.V1 ? SRV_READ_HASH_Request_HashRetrievalType_Values.SRV_HASH_RETRIEVE_HASH_BASED : SRV_READ_HASH_Request_HashRetrievalType_Values.SRV_HASH_RETRIEVE_FILE_BASED,
                            0,
                            uint.MaxValue,
                            out hashHeader,
                            out hashData) == Smb2Status.STATUS_SUCCESS,
                        testConfig.Timeout,
                        testConfig.RetryInterval);

                    testSite.Assert.AreNotEqual(
                        0,
                        hashData.Length,
                        "The content server should return content information in READ_HASH_RESPONSE");

                    return(hashData);
                }

            default:
                throw new NotImplementedException();
            }
        }
        public byte[] RetrieveContentData(string filename)
        {
            switch (testConfig.ContentTransport)
            {
                case ContentInformationTransport.PCCRTP:

                    PccrtpClient pccrtpClient = new PccrtpClient();
                    PccrtpRequest pccrtpRequest = pccrtpClient.CreatePccrtpRequest(
                        testConfig.ContentServerComputerName,
                        testConfig.ContentServerHTTPListenPort,
                        filename);

                    PccrtpResponse pccrtpResponse = pccrtpClient.SendHttpRequest(
                        Microsoft.Protocols.TestTools.StackSdk.BranchCache.Pccrtp.HttpVersionType.HttpVersion11,
                        pccrtpRequest,
                        (int)testConfig.Timeout.TotalMilliseconds);

                    testSite.Assert.AreNotEqual(
                       "peerdist",
                       pccrtpResponse.HttpResponse.ContentEncoding,
                       "The content server should not have content information ready yet");

                    return pccrtpResponse.PayloadData;

                case ContentInformationTransport.SMB2:

                    using (BranchCacheSmb2ClientTransport smb2Client = new BranchCacheSmb2ClientTransport(testConfig.Timeout, testSite, testConfig.SupportBranchCacheV1, testConfig.SupportBranchCacheV2))
                    {
                        smb2Client.OpenFile(
                            testConfig.ContentServerComputerName,
                            testConfig.SharedFolderName,
                            filename,
                            testConfig.SecurityPackageType,
                            testConfig.DomainName,
                            testConfig.UserName,
                            testConfig.UserPassword,
                            AccessMask.GENERIC_READ);

                        HASH_HEADER hashHeader;
                        byte[] hashData = null;

                        uint status = 0;

                        if (testConfig.SupportBranchCacheV1)
                        {
                            status = smb2Client.ReadHash(
                                SRV_READ_HASH_Request_HashType_Values.SRV_HASH_TYPE_PEER_DIST,
                                SRV_READ_HASH_Request_HashVersion_Values.SRV_HASH_VER_1,
                                SRV_READ_HASH_Request_HashRetrievalType_Values.SRV_HASH_RETRIEVE_HASH_BASED,
                                0,
                                uint.MaxValue,
                                out hashHeader,
                                out hashData);

                            testSite.Assert.AreNotEqual(
                                Smb2Status.STATUS_SUCCESS,
                                status,
                                "The content server should not have content information ready yet");

                            testSite.CaptureRequirementIfAreEqual(
                                Smb2Status.STATUS_HASH_NOT_PRESENT,
                                status,
                                RequirementCategory.HashNotPresent,
                                RequirementCategory.HashNotPresentMessage);
                        }

                        if (testConfig.SupportBranchCacheV2)
                        {
                            status = smb2Client.ReadHash(
                                SRV_READ_HASH_Request_HashType_Values.SRV_HASH_TYPE_PEER_DIST,
                                SRV_READ_HASH_Request_HashVersion_Values.SRV_HASH_VER_2,
                                SRV_READ_HASH_Request_HashRetrievalType_Values.SRV_HASH_RETRIEVE_FILE_BASED,
                                0,
                                uint.MaxValue,
                                out hashHeader,
                                out hashData);

                            testSite.Assert.AreNotEqual(
                                Smb2Status.STATUS_SUCCESS,
                                status,
                                "The content server should not have content information ready yet");

                            testSite.CaptureRequirementIfAreEqual(
                                Smb2Status.STATUS_HASH_NOT_PRESENT,
                                status,
                                RequirementCategory.HashNotPresent,
                                RequirementCategory.HashNotPresentMessage);
                        }

                        return smb2Client.ReadAllBytes();
                    }

                default:
                    throw new NotImplementedException();
            }
        }