public void AzureSmsStorage_WithValidRecords_ShouldBeAbleToInsertAndQueue()
        {
            // Arrange
            var connectionString = CloudConfigurationManager.GetSetting("StorageConnectionString");

            var tableName = string.Format("test{0}", Guid.NewGuid().ToString("N"));
            var queueName = string.Format("test{0}", Guid.NewGuid().ToString("N"));

            var table = AzureTestUtility.CreateCloudTable(connectionString, tableName);
            var queue = AzureTestUtility.CreateCloudQueue(connectionString, queueName);

            var smsMessage1 = AzureTestUtility.GenerateMockSmsMessage();
            var smsMessage2 = AzureTestUtility.GenerateMockSmsMessage();

            var dal = new AzureSmsStorage(table, queue);

            // Act
            var insertResult1 = dal.Insert(smsMessage1);
            var queueResult1  = dal.Queue(insertResult1);
            var queueResult2  = dal.InsertThenQueue(smsMessage2);

            queue.FetchAttributes();
            var cachedMessageCount = queue.ApproximateMessageCount;

            // Assert
            Assert.IsTrue(AzureTestUtility.IsIdentical(smsMessage1, queueResult1));
            Assert.IsTrue(AzureTestUtility.IsIdentical(smsMessage2, queueResult2));
            Assert.AreEqual(cachedMessageCount, 2);

            // Clean up
            AzureTestUtility.DeleteCloudTable(table);
            AzureTestUtility.DeleteCloudQueue(queue);
        }
        public void AzureSmsStorage_WithValidRecords_ShouldBeAbleToInsertAndRead()
        {
            // Arrange
            var connectionString = CloudConfigurationManager.GetSetting("StorageConnectionString");

            var tableName = string.Format("test{0}", Guid.NewGuid().ToString("N"));
            var queueName = string.Format("test{0}", Guid.NewGuid().ToString("N"));

            var table = AzureTestUtility.CreateCloudTable(connectionString, tableName);
            var queue = AzureTestUtility.CreateCloudQueue(connectionString, queueName);

            var smsMessage = AzureTestUtility.GenerateMockSmsMessage();

            var dal = new AzureSmsStorage(table, queue);

            // Act
            dal.Insert(smsMessage);
            var resultFast = dal.Read(smsMessage.To, smsMessage.Guid);
            var resultSlow = dal.Read(smsMessage.Guid);

            // Assert
            Assert.IsTrue(AzureTestUtility.IsIdentical(smsMessage, resultFast));
            Assert.IsTrue(AzureTestUtility.IsIdentical(smsMessage, resultSlow));

            // Clean up
            AzureTestUtility.DeleteCloudTable(table);
            AzureTestUtility.DeleteCloudQueue(queue);
        }