Пример #1
0
        /// <summary>
        /// Perform XStore Replace operations on the specified entities.
        /// </summary>
        /// <param name="jobType"></param>
        /// <param name="jobId"></param>
        /// <param name="entityMessage"></param>
        protected void ReplaceXStoreEntities(
            string jobType,
            string jobId,
            string entityMessage)
        {
            for (int i = 0; i < this.numberOfPartitions; i++)
            {
                for (int j = 0; j < this.numberOfRowsPerPartition; j++)
                {
                    //
                    // Retrieve
                    //
                    string partitionKey;
                    string rowKey;
                    SampleXStoreEntity.GenerateKeys(
                        this.GenerateJobType(jobType, i),
                        this.GenerateJobId(jobId, i, j),
                        out partitionKey,
                        out rowKey);
                    TableOperation retrieveOperation = TableOperation.Retrieve <SampleXStoreEntity>(partitionKey, rowKey);
                    TableResult    retrieveResult    = this.xstoreCloudTable.Execute(retrieveOperation);

                    Assert.IsNotNull(retrieveResult, "retrieveResult = null");
                    SampleXStoreEntity retrievedEntity = (SampleXStoreEntity)retrieveResult.Result;
                    retrievedEntity.Message = this.GenerateMessage(entityMessage, i, j);
                    //
                    // Replace
                    //
                    TableOperation replaceOperation = TableOperation.Replace(retrievedEntity);
                    TableResult    replaceResult    = this.xstoreCloudTable.Execute(replaceOperation);
                    Assert.IsNotNull(replaceResult, "replaceResult = null");
                    Assert.AreEqual((int)HttpStatusCode.NoContent, replaceResult.HttpStatusCode, "entry #{0} row {1}: insertResult.HttpStatusCode mismatch", i, j);

                    //
                    // Retrieve again
                    //
                    retrieveOperation = TableOperation.Retrieve <SampleXStoreEntity>(partitionKey, rowKey);
                    retrieveResult    = this.xstoreCloudTable.Execute(retrieveOperation);
                    Assert.IsNotNull(retrieveResult, "After Replace(): retrieveResult = null");
                    SampleXStoreEntity replacedEntity = (SampleXStoreEntity)retrieveResult.Result;

                    Assert.AreEqual(
                        this.GenerateJobType(jobType, i),
                        replacedEntity.JobType,
                        "After Replace(): JobType mismatch");
                    Assert.AreEqual(
                        this.GenerateJobId(jobId, i, j),
                        replacedEntity.JobId,
                        "After Replace(): JobId mismatch");
                    Assert.AreEqual(
                        this.GenerateMessage(entityMessage, i, j),
                        replacedEntity.Message,
                        "After Replace(): Message mismatch");
                }
            }
        }
Пример #2
0
        public void RetrieveViaXStoreThenEnableRTableThenDeleteViaRTable()
        {
            // This issue happens when we transition such:
            // 1. we Retrieve using an XStore lib.
            // 2. switched to RTable lib.
            // 3. then Delete the entry using RTable lib.
            string jobType = "jobType-RetrieveXStoreEntity";
            string jobId   = "jobId-RetrieveXStoreEntity";

            //
            // Retrieve using XStore library
            //
            string partitionKey;
            string rowKey;

            SampleXStoreEntity.GenerateKeys(
                this.GenerateJobType(jobType, 0),
                this.GenerateJobId(jobId, 0, 0),
                out partitionKey,
                out rowKey);
            TableOperation retrieveOperation = TableOperation.Retrieve <SampleXStoreEntity>(partitionKey, rowKey);
            TableResult    retrieveResult    = this.xstoreCloudTable.Execute(retrieveOperation);

            Assert.IsNotNull(retrieveResult, "retrieveResult = null");
            SampleXStoreEntity retrievedEntity = (SampleXStoreEntity)retrieveResult.Result;

            Assert.AreEqual(
                this.GenerateMessage(this.message, 0, 0),
                retrievedEntity.Message,
                "Retrieve(): Message mismatch");


            //
            // we switch to RTable and convertXSToreTableMode = true
            //
            Assert.True(this.configurationWrapper.IsConvertToRTableMode(), "Convert flag should be True");

            //
            // Delete using RTable library
            //
            InitDynamicReplicatedTableEntity deleteTableEntity = SampleXStoreEntity.ToInitDynamicReplicatedTableEntity(retrievedEntity);

            TableOperation deleteOperation = TableOperation.Delete(deleteTableEntity);
            TableResult    deleteResult    = this.repTable.Execute(deleteOperation);

            Assert.IsNotNull(deleteResult, "deleteResult = null");

            retrieveOperation = TableOperation.Retrieve(partitionKey, rowKey);
            retrieveResult    = this.repTable.Execute(retrieveOperation);
            Assert.IsNotNull(retrieveResult, "retrieveResult = null");
            Assert.AreEqual(retrieveResult.HttpStatusCode, (int)HttpStatusCode.NotFound, "entry should not exist!");

            this.PerformInsertOperationAndValidate(jobType, jobId, this.message);
            this.PerformRetrieveOperationAndValidate(jobType, jobId, this.message, true); // check _rtable_ViewId
        }
Пример #3
0
        /// <summary>
        /// Retrieve an SampleXStoreEntity which doesn't inherit ReplicatedTableEntity through RTable in convert mode
        /// </summary>
        /// <param name="jobType"></param>
        /// <param name="jobId"></param>
        /// <param name="entityMessage"></param>
        protected void RetrieveAsSampleXStoreEntity(
            string jobType,
            string jobId,
            string entityMessage)
        {
            for (int i = 0; i < this.numberOfPartitions; i++)
            {
                for (int j = 0; j < this.numberOfRowsPerPartition; j++)
                {
                    //
                    // Retrieve
                    //
                    string partitionKey;
                    string rowKey;
                    SampleXStoreEntity.GenerateKeys(
                        this.GenerateJobType(jobType, i),
                        this.GenerateJobId(jobId, i, j),
                        out partitionKey,
                        out rowKey);
                    TableOperation retrieveOperation = TableOperation.Retrieve(partitionKey, rowKey);
                    TableResult    retrieveResult    = this.repTable.Execute(retrieveOperation);

                    Assert.IsNotNull(retrieveResult, "retrieveResult = null");
                    DynamicReplicatedTableEntity dynamicReplicatedTableEntity = retrieveResult.Result as DynamicReplicatedTableEntity;
                    Assert.IsNotNull(dynamicReplicatedTableEntity, "dynamicReplicatedTableEntity = null");

                    SampleXStoreEntity retrievedEntity = SampleXStoreEntity.ToSampleXStoreEntity(dynamicReplicatedTableEntity);

                    Assert.AreEqual(
                        this.GenerateJobType(jobType, i),
                        retrievedEntity.JobType,
                        "JobType mismatch");
                    Assert.AreEqual(
                        this.GenerateJobId(jobId, i, j),
                        retrievedEntity.JobId,
                        "JobId mismatch");
                    Assert.AreEqual(
                        this.GenerateMessage(entityMessage, i, j),
                        retrievedEntity.Message,
                        "Message mismatch");
                }
            }
        }