コード例 #1
0
        public void Backend_DataSourceBackendTable_ConvertFromEntityList_Valid_List_Should_Return()
        {
            // Arrange
            DataSourceBackend.SetTestingMode(true);
            var backend = DataSourceBackendTable.Instance;

            var temp = new DataSourceBackendTableEntity
            {
                PartitionKey = "pk",
                RowKey       = "rk"
            };
            var tempblob = new AvatarItemModel();

            var entity = backend.ConvertToEntity <AvatarItemModel>(tempblob, temp.PartitionKey, temp.RowKey);

            var data = new List <DataSourceBackendTableEntity>
            {
                entity
            };

            // Act
            var result = backend.ConvertFromEntityList <AvatarItemModel>(data);

            // Reset
            DataSourceBackend.Instance.Reset();
            DataSourceBackend.SetTestingMode(false);

            // Assert
            Assert.IsNotNull(result, TestContext.TestName);
        }
コード例 #2
0
        public bool AddAccessHistoryToInitialTable(string tableName, DataSourceEnum dataSourceEnum = DataSourceEnum.Unknown)
        {
            var Table = GetTable(dataSourceEnum, tableName);

            var entity = new DataSourceBackendTableEntity
            {
                Blob         = "{}",
                PartitionKey = "Access",
                RowKey       = DateTimeHelper.Instance.GetDateTimeNowUTC().ToString("yy-mm-dd hh:mm:ss FFFFFF")
            };

            /*
             * Mike Fixup
             * Refactor to work with Core
             *
             * var updateOperation = TableOperation.InsertOrReplace(entity);
             * var query = Table.Execute(updateOperation);
             * if (query.Result == null)
             * {
             *  return false;
             * }
             */

            return(true);
        }
コード例 #3
0
        public void DataSourceBackendTableEntity_Default_Instantiate_With_Keys_Should_Pass()
        {
            // Act
            var result = new DataSourceBackendTableEntity("pk", "rk");

            // Assert
            Assert.IsNotNull(result, TestContext.TestName);
        }
コード例 #4
0
        public void Models_DataSourceBackendTableEntity_Default_Instantiate_Should_Pass()
        {
            // Act
            var result = new DataSourceBackendTableEntity();

            // Assert
            Assert.IsNotNull(result, TestContext.TestName);
        }
コード例 #5
0
        public void DataSourceBackendTableEntity_Default_Blob_Get_Should_Pass()
        {
            // Arrange
            var data = new DataSourceBackendTableEntity("pk", "rk", "123");

            // Act
            var result = data.Blob;

            // Assert
            Assert.IsNotNull(result, TestContext.TestName);
        }
コード例 #6
0
        public void DataSourceBackendTableEntity_Default_Instantiate_With_Blob_Should_Pass()
        {
            // Arrange
            var blob = "abc";

            // Act
            var result = new DataSourceBackendTableEntity("pk", "rk", blob);

            // Assert
            Assert.IsNotNull(result, TestContext.TestName);
        }
コード例 #7
0
ファイル: DataSourceBackendTable.cs プロジェクト: alymlk/5051
        /// <summary>
        /// Convert the data item to an entity
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public DataSourceBackendTableEntity ConvertToEntity <T>(T data, string pk, string rk)
        {
            var entity = new DataSourceBackendTableEntity
            {
                PartitionKey = pk,
                RowKey       = rk,
                Blob         = JsonConvert.SerializeObject(data)
            };

            return(entity);
        }
コード例 #8
0
        public void DataSourceBackendTableEntity_Default_Blob_Set_Should_Pass()
        {
            // Arrange
            var data   = new DataSourceBackendTableEntity("pk", "rk");
            var expect = "123";

            // Act
            data.Blob = expect;
            var result = data.Blob;

            // Assert
            Assert.AreEqual(expect, result, TestContext.TestName);
        }
コード例 #9
0
ファイル: DataSourceBackendTable.cs プロジェクト: alymlk/5051
        public bool DeleteDirect <T>(string tableName, string pk, string rk, DataSourceEnum dataSourceEnum = DataSourceEnum.Unknown)
        {
            if (string.IsNullOrEmpty(tableName))
            {
                return(false);
            }

            if (string.IsNullOrEmpty(pk))
            {
                return(false);
            }

            if (string.IsNullOrEmpty(rk))
            {
                return(false);
            }

            try
            {
                var Table = GetTable(dataSourceEnum, tableName);

                var entity = new DataSourceBackendTableEntity
                {
                    ETag         = "*",
                    PartitionKey = pk,
                    RowKey       = rk
                };

                var Operation = TableOperation.Delete(entity);
                var query     = Table.Execute(Operation);
                if (query.Result == null)
                {
                    return(false);
                }
            }
            catch (Exception) { }

            return(true);
        }
コード例 #10
0
ファイル: DataSourceBackendTable.cs プロジェクト: alymlk/5051
        /// <summary>
        /// Convert an entity to a data item
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public T ConvertFromEntity <T>(DataSourceBackendTableEntity data)
        {
            var myReturn = JsonConvert.DeserializeObject <T>(data.Blob);

            return(myReturn);
        }