本文整理汇总了C#中EventQueue.Expect方法的典型用法代码示例。如果您正苦于以下问题:C# EventQueue.Expect方法的具体用法?C# EventQueue.Expect怎么用?C# EventQueue.Expect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventQueue
的用法示例。
在下文中一共展示了EventQueue.Expect方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HostedCacheServer_PchcServer_BatchedOffer_ContentRetrieved
public void HostedCacheServer_PchcServer_BatchedOffer_ContentRetrieved()
{
CheckApplicability();
EventQueue eventQueue = new EventQueue(BaseTestSite);
eventQueue.Timeout = testConfig.Timeout;
byte[] content = TestUtility.GenerateRandomArray(ContentInformationUtility.DefaultBlockSize);
Content_Information_Data_Structure_V2 contentInformationV2 = contentInformationUtility.CreateContentInformationV2();
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Start PCCRR server to be ready to serve content to hosted cache server");
using (PccrrTestServerV2 pccrrTestServerV2 = new PccrrTestServerV2())
{
pccrrTestServerV2.Start(
testConfig.ClientContentRetrievalListenPort,
CryptoAlgoId_Values.AES_128,
contentInformationV2,
content,
eventQueue);
PCHCClient pchcClient = new PCHCClient(
TransferProtocol.HTTP,
testConfig.HostedCacheServerComputerName,
testConfig.HostedCacheServerHTTPListenPort,
PchcConsts.HttpUrl,
testConfig.DomainName,
testConfig.UserName,
testConfig.UserPassword);
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Directly Supply segment info to hosted cache server");
var batchedOfferMessage = pchcClient.CreateBatchedOfferMessage(
testConfig.ClientContentRetrievalListenPort,
contentInformationV2);
pchcClient.SendBatchedOfferMessage(batchedOfferMessage);
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Make sure all the segments in chunk 0 is retrieved by hosted cache server");
int blockCount = 0;
int totalBlockCount = contentInformationV2.GetBlockCount();
TestUtility.DoUntilSucceed(delegate()
{
eventQueue.Expect<MessageArrivedEventArgs>(typeof(PccrrServer).GetEvent("MessageArrived"), delegate(System.Net.IPEndPoint sender, PccrrPacket pccrrPacket)
{
var pccrrGetBlksRequest = pccrrPacket as PccrrGETBLKSRequestPacket;
if (pccrrGetBlksRequest != null)
{
blockCount++;
}
});
return blockCount == totalBlockCount;
}, TimeSpan.MaxValue, TimeSpan.Zero);
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Wait until cache is available on hosted cache server");
TestUtility.DoUntilSucceed(() => sutControlAdapter.IsLocalCacheExisted(testConfig.HostedCacheServerComputerFQDNOrNetBiosName), testConfig.Timeout, testConfig.RetryInterval);
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Re-supply segment info to hosted cache server");
var batchedOfferResponse = pchcClient.SendBatchedOfferMessage(batchedOfferMessage);
BaseTestSite.Assert.AreEqual(
RESPONSE_CODE.OK,
batchedOfferResponse.ResponseCode,
"Hosted cache server should return OK to batched offer message");
}
}
示例2: HostedCacheServer_BVT_CacheOfferingRetrieval_V2
public void HostedCacheServer_BVT_CacheOfferingRetrieval_V2()
{
CheckApplicability();
EventQueue eventQueue = new EventQueue(BaseTestSite);
eventQueue.Timeout = testConfig.Timeout;
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Retrieve the original content data from content server");
byte[] content = contentInformationUtility.RetrieveContentData();
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Retrieve the content information from content server");
Content_Information_Data_Structure_V2 contentInformation =
PccrcUtility.ParseContentInformationV2(contentInformationUtility.RetrieveContentInformation(BranchCacheVersion.V2));
CryptoAlgoId_Values cryptoAlgoId = CryptoAlgoId_Values.AES_128;
PccrrClient pccrrClient = new PccrrClient(testConfig.HostedCacheServerComputerName, testConfig.HostedCacheServerHTTPListenPort);
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Send PCCRR GetSegList request to HostedCacheServer to make sure that this file does not exist in HostedCacheServer.");
for (int i = 0; i < contentInformation.chunks.Length; ++i)
{
var chunk = contentInformation.chunks[i];
for (int j = 0; j < chunk.chunkData.Length; j++)
{
var pccrrGetSegListRequest = pccrrClient.CreateMsgGetSegListRequest(
cryptoAlgoId,
Guid.NewGuid(),
new byte[][] { contentInformation.GetSegmentId(i, j) });
pccrrClient.SendPacket(
pccrrGetSegListRequest,
testConfig.Timeout);
var pccrrGetSegListResponse
= (PccrrSegListResponsePacket)pccrrClient.ExpectPacket();
BaseTestSite.Assert.AreEqual<uint>(
0,
pccrrGetSegListResponse.MsgSegList.SegmentRangeCount,
"The server MUST set the SegmentRangeCount field to zero if it doesn't have the requested segments data.");
}
}
using (PccrrTestServerV2 pccrrTestServer = new PccrrTestServerV2())
{
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Start PCCRR server to be ready to serve content to hosted cache server");
pccrrTestServer.Start(
testConfig.ClientContentRetrievalListenPort,
cryptoAlgoId,
contentInformation,
content,
eventQueue);
PCHCClient pchcClient = new PCHCClient(
TransferProtocol.HTTP,
testConfig.HostedCacheServerComputerName,
testConfig.ContentServerHTTPListenPort,
PchcConsts.HttpUrl,
testConfig.DomainName,
testConfig.UserName,
testConfig.UserPassword);
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Offer all content segments to hosted cache server");
var batchedOfferMessage = pchcClient.CreateBatchedOfferMessage(
testConfig.ClientContentRetrievalListenPort,
contentInformation);
var responseMessage = pchcClient.SendBatchedOfferMessage(batchedOfferMessage);
TestClassBase.BaseTestSite.Assert.AreEqual<RESPONSE_CODE>(
RESPONSE_CODE.OK,
responseMessage.ResponseCode,
@"The hosted cache MUST send a response code of 0 when BATCHED_OFFER_MESSAGE request received");
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Make sure all segments are retrieved by hosted cache server");
int totalBlockCount = contentInformation.GetBlockCount();
int blockCount = 0;
TestUtility.DoUntilSucceed(delegate()
{
eventQueue.Expect<MessageArrivedEventArgs>(typeof(PccrrServer).GetEvent("MessageArrived"), delegate(System.Net.IPEndPoint sender, PccrrPacket pccrrPacket)
{
var pccrrGetBlksRequest = pccrrPacket as PccrrGETBLKSRequestPacket;
if (pccrrGetBlksRequest != null)
{
blockCount++;
}
});
//.........这里部分代码省略.........
示例3: HostedCacheServer_BVT_CacheOfferingRetrieval_V1
public void HostedCacheServer_BVT_CacheOfferingRetrieval_V1()
{
CheckApplicability();
EventQueue eventQueue = new EventQueue(BaseTestSite);
eventQueue.Timeout = testConfig.Timeout;
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Trigger hash generation on content server");
byte[] content = contentInformationUtility.RetrieveContentData();
Content_Information_Data_Structure contentInformation =
PccrcUtility.ParseContentInformation(contentInformationUtility.RetrieveContentInformation(BranchCacheVersion.V1));
CryptoAlgoId_Values cryptoAlgoId = CryptoAlgoId_Values.AES_128;
PccrrClient pccrrClient = new PccrrClient(testConfig.HostedCacheServerComputerName, testConfig.HostedCacheServerHTTPListenPort);
for (int i = 0; i < contentInformation.cSegments; ++i)
{
var pccrrBlkListRequest = pccrrClient.CreateMsgGetBlkListRequest(
contentInformation.GetSegmentId(i),
new BLOCK_RANGE[] { new BLOCK_RANGE { Index = 0, Count = contentInformation.segments[i].BlockCount } },
cryptoAlgoId,
MsgType_Values.MSG_GETBLKLIST);
pccrrClient.SendPacket(
pccrrBlkListRequest,
testConfig.Timeout);
var pccrrBlkListResponse
= (PccrrBLKLISTResponsePacket)pccrrClient.ExpectPacket();
BaseTestSite.Assert.AreEqual<uint>(
0,
pccrrBlkListResponse.MsgBLKLIST.BlockRangeCount,
"The server MUST set the BlockRangeCount field to zero if it doesn't have the requested blocks data.");
}
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Retrieve content information from content server");
using (PccrrTestServerV1 pccrrTestServer = new PccrrTestServerV1())
{
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Start PCCRR server to be ready to serve content to hosted cache server");
pccrrTestServer.Start(
testConfig.ClientContentRetrievalListenPort,
cryptoAlgoId,
contentInformation,
content,
eventQueue);
PCHCClient pchcClient = new PCHCClient(
TransferProtocol.HTTPS,
testConfig.HostedCacheServerComputerName,
testConfig.HostedCacheServerHTTPSListenPort,
PchcConsts.HttpsUrl,
testConfig.DomainName,
testConfig.UserName,
testConfig.UserPassword);
for (int i = 0; i < contentInformation.cSegments; i++)
{
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Offer content segment {0} to hosted cache server",
i);
INITIAL_OFFER_MESSAGE initialOfferMessage = pchcClient.CreateInitialOfferMessage(
testConfig.ClientContentRetrievalListenPort,
contentInformation.GetSegmentId(i));
Microsoft.Protocols.TestTools.StackSdk.BranchCache.Pchc.RESPONSE_MESSAGE responseMessage
= pchcClient.SendInitialOfferMessage(initialOfferMessage);
TestClassBase.BaseTestSite.Assert.AreEqual<RESPONSE_CODE>(
RESPONSE_CODE.INTERESTED,
responseMessage.ResponseCode,
@"The hosted cache MUST specify a response code of 1
if its list of block hashes associated with the segment is incomplete.");
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Supply segment info to hosted cache server");
SEGMENT_INFO_MESSAGE segmentInfoMessage = pchcClient.CreateSegmentInfoMessage(
testConfig.ClientContentRetrievalListenPort,
contentInformation,
i);
responseMessage = pchcClient.SendSegmentInfoMessage(segmentInfoMessage);
TestClassBase.BaseTestSite.Assert.AreEqual<RESPONSE_CODE>(
RESPONSE_CODE.OK,
responseMessage.ResponseCode,
@"The hosted cache MUST send a response code of 0 when SEGMENT_INFO_MESSAGE request received");
BaseTestSite.Log.Add(
//.........这里部分代码省略.........
示例4: HostedCacheServer_PchcServer_InitialOffer_ContentRereieved
public void HostedCacheServer_PchcServer_InitialOffer_ContentRereieved()
{
CheckApplicability();
EventQueue eventQueue = new EventQueue(BaseTestSite);
eventQueue.Timeout = testConfig.Timeout;
Content_Information_Data_Structure contentInformation = contentInformationUtility.CreateContentInformationV1();
CryptoAlgoId_Values cryptoAlgoId = CryptoAlgoId_Values.AES_128;
using (PccrrTestServerV1 pccrrTestServer = new PccrrTestServerV1())
{
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Start PCCRR server to be ready to serve content to hosted cache server");
pccrrTestServer.Start(
testConfig.ClientContentRetrievalListenPort,
cryptoAlgoId,
new ProtoVersion { MajorVersion = 1, MinorVersion = 0 },
contentInformation,
TestUtility.GenerateRandomArray(ContentInformationUtility.DefaultBlockSize),
eventQueue);
PCHCClient pchcClient = new PCHCClient(
TransferProtocol.HTTPS,
testConfig.HostedCacheServerComputerName,
testConfig.HostedCacheServerHTTPSListenPort,
PchcConsts.HttpsUrl,
testConfig.DomainName,
testConfig.UserName,
testConfig.UserPassword);
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Send initial offer message to hosted cache server");
SEGMENT_INFO_MESSAGE segmentInfoMessage = pchcClient.CreateSegmentInfoMessage(
testConfig.ClientContentRetrievalListenPort,
contentInformation,
0);
pchcClient.SendSegmentInfoMessage(segmentInfoMessage);
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Make sure all blocks in segment 0 are retrieved by hosted cache server");
int blockCount = 0;
TestUtility.DoUntilSucceed(delegate()
{
eventQueue.Expect<MessageArrivedEventArgs>(typeof(PccrrServer).GetEvent("MessageArrived"), delegate(System.Net.IPEndPoint sender, PccrrPacket pccrrPacket)
{
var pccrrGetBlksRequest = pccrrPacket as PccrrGETBLKSRequestPacket;
if (pccrrGetBlksRequest != null)
{
blockCount++;
}
});
return blockCount == contentInformation.segments[0].BlockCount;
}, TimeSpan.MaxValue, TimeSpan.Zero);
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Wait until cache is available on hosted cache server");
TestUtility.DoUntilSucceed(() => sutControlAdapter.IsLocalCacheExisted(testConfig.HostedCacheServerComputerFQDNOrNetBiosName), testConfig.Timeout, testConfig.RetryInterval);
INITIAL_OFFER_MESSAGE initialOfferMessage = pchcClient.CreateInitialOfferMessage(
testConfig.ClientContentRetrievalListenPort,
contentInformation.GetSegmentId(0));
Microsoft.Protocols.TestTools.StackSdk.BranchCache.Pchc.RESPONSE_MESSAGE responseMessage2
= pchcClient.SendInitialOfferMessage(initialOfferMessage);
TestClassBase.BaseTestSite.Assert.AreEqual<RESPONSE_CODE>(
RESPONSE_CODE.INTERESTED,
responseMessage2.ResponseCode,
@"The hosted cache MUST specify a response code of 0
if it already has block data and block hash.");
}
}
示例5: HostedCacheServer_PccrrServer_MessageHeader_CryptoAlgoId
public void HostedCacheServer_PccrrServer_MessageHeader_CryptoAlgoId(CryptoAlgoId_Values algoId)
{
CheckApplicability();
EventQueue eventQueue = new EventQueue(BaseTestSite);
eventQueue.Timeout = testConfig.Timeout;
byte[] content = TestUtility.GenerateRandomArray(ContentInformationUtility.DefaultBlockSize);
Content_Information_Data_Structure contentInformation = contentInformationUtility.CreateContentInformationV1();
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Start PCCRR server to be ready to serve content to hosted cache server");
using (PccrrTestServerV1 pccrrTestServer = new PccrrTestServerV1())
{
pccrrTestServer.Start(
testConfig.ClientContentRetrievalListenPort,
algoId,
new ProtoVersion { MajorVersion = 1, MinorVersion = 0 },
contentInformation,
content,
eventQueue);
PCHCClient pchcClient = new PCHCClient(
TransferProtocol.HTTPS,
testConfig.HostedCacheServerComputerName,
testConfig.HostedCacheServerHTTPSListenPort,
PchcConsts.HttpsUrl,
testConfig.DomainName,
testConfig.UserName,
testConfig.UserPassword);
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Directly Supply segment info to hosted cache server");
SEGMENT_INFO_MESSAGE segmentInfoMessage = pchcClient.CreateSegmentInfoMessage(
testConfig.ClientContentRetrievalListenPort,
contentInformation,
0);
pchcClient.SendSegmentInfoMessage(segmentInfoMessage);
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Make sure block 0 in segment 0 is retrieved by hosted cache server");
int blockCount = 0;
TestUtility.DoUntilSucceed(delegate()
{
eventQueue.Expect<MessageArrivedEventArgs>(typeof(PccrrServer).GetEvent("MessageArrived"), delegate(System.Net.IPEndPoint sender, PccrrPacket pccrrPacket)
{
var pccrrGetBlksRequest = pccrrPacket as PccrrGETBLKSRequestPacket;
if (pccrrGetBlksRequest != null)
{
blockCount++;
}
});
return blockCount == 1;
}, TimeSpan.MaxValue, TimeSpan.Zero);
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Wait until cache is available on hosted cache server");
TestUtility.DoUntilSucceed(() => sutControlAdapter.IsLocalCacheExisted(testConfig.HostedCacheServerComputerFQDNOrNetBiosName), testConfig.Timeout, testConfig.RetryInterval);
}
PccrrClient pccrrClient = new PccrrClient(testConfig.HostedCacheServerComputerName, testConfig.HostedCacheServerHTTPListenPort);
Aes aes = PccrrUtitlity.CreateAes(algoId);
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Retrieve block 0 in segment 0 from hosted cache server");
PccrrGETBLKSRequestPacket pccrrBlkRequest = pccrrClient.CreateMsgGetBlksRequest(
contentInformation.GetSegmentId(0),
algoId,
MsgType_Values.MSG_GETBLKS,
(uint)0,
1);
pccrrClient.SendPacket(
pccrrBlkRequest,
testConfig.Timeout);
PccrrBLKResponsePacket pccrrBlkResponse
= (PccrrBLKResponsePacket)pccrrClient.ExpectPacket();
byte[] block = pccrrBlkResponse.MsgBLK.Block;
if (algoId != CryptoAlgoId_Values.NoEncryption)
block = PccrrUtitlity.Decrypt(aes, block, contentInformation.segments[0].SegmentSecret, pccrrBlkResponse.MsgBLK.IVBlock);
BaseTestSite.Assert.IsTrue(
Enumerable.SequenceEqual(content, block),
"The retrieved cached data should be the same as server data.");
}
示例6: HostedCacheServer_PccrrClient_MessageHeader_TypeInvalidV2
public void HostedCacheServer_PccrrClient_MessageHeader_TypeInvalidV2()
{
CheckApplicability();
EventQueue eventQueue = new EventQueue(BaseTestSite);
eventQueue.Timeout = testConfig.Timeout;
Content_Information_Data_Structure_V2 contentInformationV2 = contentInformationUtility.CreateContentInformationV2();
CryptoAlgoId_Values cryptoAlgoId = CryptoAlgoId_Values.AES_128;
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Start PCCRR server to be ready to serve content to hosted cache server");
using (PccrrTestInvalidMsgTypeServerV2 pccrrTestServerV2 = new PccrrTestInvalidMsgTypeServerV2())
{
pccrrTestServerV2.StartListen(
testConfig.ClientContentRetrievalListenPort,
cryptoAlgoId,
contentInformationV2,
new byte[0],
eventQueue);
PCHCClient pchcClient = new PCHCClient(
TransferProtocol.HTTP,
testConfig.HostedCacheServerComputerName,
testConfig.ContentServerHTTPListenPort,
PchcConsts.HttpUrl,
testConfig.DomainName,
testConfig.UserName,
testConfig.UserPassword);
var batchedOfferMessage = pchcClient.CreateBatchedOfferMessage(
testConfig.ClientContentRetrievalListenPort,
contentInformationV2);
var responseMessage = pchcClient.SendBatchedOfferMessage(batchedOfferMessage);
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Offer PccrrBLKSResponse with invalid message type to hosted cache server");
int blockCount = 0;
TestUtility.DoUntilSucceed(delegate()
{
eventQueue.Expect<MessageArrivedEventArgs>(typeof(PccrrServer).GetEvent("MessageArrived"), delegate(System.Net.IPEndPoint sender, PccrrPacket pccrrPacket)
{
var pccrrGetBlksRequest = pccrrPacket as PccrrGETBLKSRequestPacket;
if (pccrrGetBlksRequest != null)
{
blockCount++;
}
});
return blockCount == 1;
}, TimeSpan.MaxValue, TimeSpan.Zero);
TestUtility.DoUntilSucceed(() => sutControlAdapter.IsLocalCacheExisted(testConfig.HostedCacheServerComputerFQDNOrNetBiosName), testConfig.NegativeTestTimeout, testConfig.RetryInterval);
}
}
示例7: HostedCacheServer_PccrrClient_MessageHeader_ProtoVerIncompatible
public void HostedCacheServer_PccrrClient_MessageHeader_ProtoVerIncompatible()
{
CheckApplicability();
EventQueue eventQueue = new EventQueue(BaseTestSite);
eventQueue.Timeout = testConfig.Timeout;
Content_Information_Data_Structure contentInformation = contentInformationUtility.CreateContentInformationV1();
CryptoAlgoId_Values cryptoAlgoId = CryptoAlgoId_Values.AES_128;
ProtoVersion protoVersion = new ProtoVersion { MajorVersion = 1, MinorVersion = 0 };
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Start PCCRR server to be ready to serve content to hosted cache server");
using (PccrrTestIncompatibleProtoVerServer pccrrTestServer = new PccrrTestIncompatibleProtoVerServer())
{
pccrrTestServer.Start(
testConfig.ClientContentRetrievalListenPort,
cryptoAlgoId,
protoVersion,
contentInformation,
new byte[0],
eventQueue);
PCHCClient pchcClient = new PCHCClient(
TransferProtocol.HTTPS,
testConfig.HostedCacheServerComputerName,
testConfig.HostedCacheServerHTTPSListenPort,
PchcConsts.HttpsUrl,
testConfig.DomainName,
testConfig.UserName,
testConfig.UserPassword);
SEGMENT_INFO_MESSAGE segmentInfoMessage = pchcClient.CreateSegmentInfoMessage(
testConfig.ClientContentRetrievalListenPort,
contentInformation,
0);
pchcClient.SendSegmentInfoMessage(segmentInfoMessage);
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Offer PccrrBLKSResponse with incompatible proto version to hosted cache server");
int blockCount = 0;
TestUtility.DoUntilSucceed(delegate()
{
eventQueue.Expect<MessageArrivedEventArgs>(typeof(PccrrServer).GetEvent("MessageArrived"), delegate(System.Net.IPEndPoint sender, PccrrPacket pccrrPacket)
{
var pccrrGetBlksRequest = pccrrPacket as PccrrGETBLKSRequestPacket;
if (pccrrGetBlksRequest != null)
{
blockCount++;
}
});
return blockCount == 1;
}, TimeSpan.MaxValue, TimeSpan.Zero);
TestUtility.DoUntilSucceed(() => sutControlAdapter.IsLocalCacheExisted(testConfig.HostedCacheServerComputerFQDNOrNetBiosName), testConfig.NegativeTestTimeout, testConfig.RetryInterval);
}
}
示例8: HostedCacheServer_PccrrClient_MessageHeader_CryptoAlgoIdV2
public void HostedCacheServer_PccrrClient_MessageHeader_CryptoAlgoIdV2(CryptoAlgoId_Values algoId)
{
CheckApplicability();
EventQueue eventQueue = new EventQueue(BaseTestSite);
eventQueue.Timeout = testConfig.Timeout;
byte[] content = TestUtility.GenerateRandomArray(ContentInformationUtility.DefaultBlockSize);
Content_Information_Data_Structure_V2 contentInformationV2 = contentInformationUtility.CreateContentInformationV2();
ProtoVersion protoVersion = new ProtoVersion { MajorVersion = 2, MinorVersion = ushort.MaxValue };
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Start PCCRR server to be ready to serve content to hosted cache server");
using (PccrrTestServerV2 pccrrTestServerV2 = new PccrrTestServerV2())
{
pccrrTestServerV2.Start(
testConfig.ClientContentRetrievalListenPort,
algoId,
contentInformationV2,
content,
eventQueue);
PCHCClient pchcClient = new PCHCClient(
TransferProtocol.HTTP,
testConfig.HostedCacheServerComputerName,
testConfig.HostedCacheServerHTTPListenPort,
PchcConsts.HttpUrl,
testConfig.DomainName,
testConfig.UserName,
testConfig.UserPassword);
var batchedOfferMessage = pchcClient.CreateBatchedOfferMessage(
testConfig.ClientContentRetrievalListenPort,
contentInformationV2);
pchcClient.SendBatchedOfferMessage(batchedOfferMessage);
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Offer content segment 0 of chunk 0 to hosted cache server");
int segmentCount = 0;
TestUtility.DoUntilSucceed(delegate()
{
eventQueue.Expect<MessageArrivedEventArgs>(typeof(PccrrServer).GetEvent("MessageArrived"), delegate(System.Net.IPEndPoint sender, PccrrPacket pccrrPacket)
{
var pccrrGetBlksRequest = pccrrPacket as PccrrGETBLKSRequestPacket;
if (pccrrGetBlksRequest != null)
{
segmentCount++;
}
});
return segmentCount == 1;
}, TimeSpan.MaxValue, TimeSpan.Zero);
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Wait until cache is available on hosted cache server");
TestUtility.DoUntilSucceed(() => sutControlAdapter.IsLocalCacheExisted(testConfig.HostedCacheServerComputerFQDNOrNetBiosName), testConfig.Timeout, testConfig.RetryInterval);
}
PccrrClient pccrrClient = new PccrrClient(testConfig.HostedCacheServerComputerName, testConfig.HostedCacheServerHTTPListenPort);
Aes aes = PccrrUtitlity.CreateAes(algoId);
BaseTestSite.Log.Add(
LogEntryKind.Debug,
"Retrieve segment 0 of chunk 0 from hosted cache server",
0);
PccrrGETBLKSRequestPacket pccrrBlkRequest = pccrrClient.CreateMsgGetBlksRequest(
contentInformationV2.GetSegmentId(0,0),
algoId,
MsgType_Values.MSG_GETBLKS,
(uint)0,
1);
pccrrClient.SendPacket(
pccrrBlkRequest,
testConfig.Timeout);
PccrrBLKResponsePacket pccrrBlkResponse
= (PccrrBLKResponsePacket)pccrrClient.ExpectPacket();
byte[] data = pccrrBlkResponse.MsgBLK.Block;
if (algoId != CryptoAlgoId_Values.NoEncryption)
data = PccrrUtitlity.Decrypt(aes, data, contentInformationV2.chunks[0].chunkData[0].SegmentSecret, pccrrBlkResponse.MsgBLK.IVBlock);
BaseTestSite.Assert.IsTrue(
Enumerable.SequenceEqual(content.Take((int)contentInformationV2.chunks[0].chunkData[0].cbSegment), data),
"The retrieved cached data should be the same as server data.");
}