public void ToFromBinaryTest() { KMeansJobData target = new KMeansJobData(Guid.NewGuid(), 1, null, 2, 10, DateTime.Now); byte[] bytes = target.ToBinary(); KMeansJobData targetNew = KMeansJobData.FromMessage(new CloudQueueMessage(bytes)) as KMeansJobData; Assert.AreEqual(target.JobID, targetNew.JobID); Assert.AreEqual(target.K, targetNew.K); Assert.AreEqual(target.N, targetNew.N); }
public void AzureMessageEnqueueDequeueTest() { CloudQueue queue = AzureHelper.StorageAccount.CreateCloudQueueClient().GetQueueReference(AzureHelper.ServerRequestQueue); queue.CreateIfNotExist(); queue.Clear(); AzureMessage message = new KMeansJobData(Guid.NewGuid(), 1, null, 2, 10, DateTime.Now); queue.AddMessage(new CloudQueueMessage(message.ToBinary())); Thread.Sleep(2000); AzureMessage received = KMeansJobData.FromMessage(queue.GetMessage()); KMeansJobData messageCast = message as KMeansJobData, receivedCast = received as KMeansJobData; Assert.AreEqual(messageCast.JobID, receivedCast.JobID); Assert.AreEqual(messageCast.K, receivedCast.K); Assert.AreEqual(messageCast.N, receivedCast.N); }