Exemple #1
0
        public void Migrate2CosmosInsertGetDeleteExplicitLiveTest()
        {
            #region arrange
            bool     expected   = true;
            string[] store_args = new string[4] {
                "DefaultEndpointsProtocol=https;AccountName=0100lanciostorage;AccountKey=KIZ/Su4EvRebOilwawZQkTWlXs6gKDO76S4uXD1q0ss7GNg5f7DC66i39Ln2B/rl/mjPjSYtigZDnOsWKDrRSg==;EndpointSuffix=core.windows.net",
                "MigrateTokenTableTest",
                "TokenID",
                "TokenValue"
            };

            string partitionKey = "TokenID";
            string rowKey       = "12345678";

            Dictionary <string, object> filter_get = new Dictionary <string, object>()
            {
                { "PartitionKey", partitionKey },
                { "RowKey", rowKey },
            };

            Dictionary <string, object> filter_del = new Dictionary <string, object>()
            {
                { "PartitionKey", partitionKey },
            };
            #endregion

            #region insert
            IStore store = new TableStorageStore(store_args);
            Dictionary <string, object> entry = new Dictionary <string, object>()
            {
                { "TokenID", partitionKey },
                { "TokenValue", rowKey },
                { "ValidUntil", DateTime.Now.AddDays(10) },
            };
            bool actual = store.set(entry);

            Assert.AreEqual(expected, actual);
            #endregion

            #region get

            object element = store.get(filter_get);

            Assert.IsNotNull(element);
            Assert.IsInstanceOfType(element, typeof(Dictionary <string, object>));
            Dictionary <string, object> actualElement = (Dictionary <string, object>)element;
            Assert.IsTrue(actualElement.ContainsKey("TokenID"));
            Assert.IsTrue(actualElement.ContainsKey("TokenValue"));
            Assert.IsTrue(actualElement.ContainsKey("ValidUntil"));
            Assert.AreEqual(entry["TokenID"], actualElement["TokenID"]);
            Assert.AreEqual(entry["TokenValue"], actualElement["TokenValue"]);
            //Assert.AreEqual(entry["ValidUntil"], actualElement["ValidUntil"]);
            #endregion

            #region delete
            actual = store.del(filter_del);

            Assert.AreEqual(expected, actual);
            #endregion
        }
Exemple #2
0
        public void Migrate2CosmosInsertGetDeleteDevelopmentTest()
        {
            #region arrange
            bool     expected   = true;
            string[] store_args = new string[4] {
                "UseDevelopmentStorage=true",
                "MigrateTokenTable",
                "TokenID",
                "TokenValue"
            };

            string partitionKey = "TokenID";
            string rowKey       = "12345678";

            Dictionary <string, object> filter_get = new Dictionary <string, object>()
            {
                { "PartitionKey", partitionKey },
                { "RowKey", rowKey },
            };

            Dictionary <string, object> filter_del = new Dictionary <string, object>()
            {
                { "PartitionKey", partitionKey },
            };
            #endregion

            #region insert
            IStore store = new TableStorageStore(store_args);
            Dictionary <string, object> entry = new Dictionary <string, object>()
            {
                { "TokenID", partitionKey },
                { "TokenValue", rowKey },
                { "ValidUntil", DateTime.Now.AddDays(10) },
            };
            bool actual = store.set(entry);

            Assert.AreEqual(expected, actual);
            #endregion

            #region get

            object element = store.get(filter_get);

            Assert.IsNotNull(element);
            Assert.IsInstanceOfType(element, typeof(Dictionary <string, object>));
            Dictionary <string, object> actualElement = (Dictionary <string, object>)element;
            Assert.IsTrue(actualElement.ContainsKey("TokenID"));
            Assert.IsTrue(actualElement.ContainsKey("TokenValue"));
            Assert.IsTrue(actualElement.ContainsKey("ValidUntil"));
            Assert.AreEqual(entry["TokenID"], actualElement["TokenID"]);
            Assert.AreEqual(entry["TokenValue"], actualElement["TokenValue"]);
            Assert.AreEqual(entry["ValidUntil"], actualElement["ValidUntil"]);
            #endregion

            #region delete
            actual = store.del(filter_del);

            Assert.AreEqual(expected, actual);
            #endregion
        }
Exemple #3
0
        public void DeleteInsertGetDevelopmentTest()
        {
            #region arrange
            bool     expected_del = true;
            bool     expected_set = true;
            string[] store_args   = new string[4] {
                "UseDevelopmentStorage=true",
                "TestTable",
                "myPK",
                "myRK"
            };

            string myPK = "131313";
            string myRK = "242424";

            Dictionary <string, object> entry = new Dictionary <string, object>()
            {
                { "PartitionKey", myPK },
                { "RowKey", myRK },
                { "MyFirstElement", 11 },
                { "MySecondElement", 22 }
            };

            Dictionary <string, object> filter = new Dictionary <string, object>()
            {
                { "PartitionKey", myPK },
                { "RowKey", myRK },
            };
            #endregion

            #region delete and then insert
            IStore store      = new TableStorageStore(store_args);
            bool   actual_del = store.del(filter);
            bool   actual_set = store.set(entry);
            object element    = store.get(filter);
            Dictionary <string, object> actual = store.ToDictionary(element);
            #endregion

            #region assert
            Assert.AreEqual(expected_del, actual_del);
            Assert.AreEqual(expected_set, actual_set);
            Assert.AreEqual(entry["PartitionKey"], actual["myPK"]);
            Assert.AreEqual(entry["RowKey"], actual["myRK"]);
            Assert.AreEqual(entry["MyFirstElement"], actual["MyFirstElement"]);
            Assert.AreEqual(entry["MySecondElement"], actual["MySecondElement"]);
            #endregion
        }