Esempio n. 1
0
        private static void PrepareSourceData()
        {
            PrepareDirSourceData(5 * 1024 * 1024);
            PrepareSingleObjectSourceData(5 * 1024 * 1024);

            // Generate source data
            foreach (var pair in sourceDataInfos)
            {
                DMLibDataType sourceDataType;
                if (Enum.TryParse <DMLibDataType>(pair.Key, out sourceDataType))
                {
                    DataAdaptor <DMLibDataInfo> sourceAdaptor = GetSourceAdaptor(sourceDataType);
                    sourceAdaptor.Cleanup();
                    sourceAdaptor.CreateIfNotExists();

                    sourceAdaptor.GenerateData(pair.Value);
                }
            }

            // Generate source data for URI source separately since it's destination related
            DataAdaptor <DMLibDataInfo> uriSourceAdaptor = GetSourceAdaptor(DMLibDataType.URI);

            uriSourceAdaptor.Cleanup();
            uriSourceAdaptor.CreateIfNotExists();

            DMLibTestContext.SourceType = DMLibDataType.URI;
            DMLibTestContext.CopyMethod = DMLibCopyMethod.ServiceSideAsyncCopy;

            DMLibDataType[] uriDestDataTypes = { DMLibDataType.CloudFile, DMLibDataType.BlockBlob, DMLibDataType.PageBlob, DMLibDataType.AppendBlob };
            foreach (DMLibDataType uriDestDataType in uriDestDataTypes)
            {
                DMLibTestContext.DestType = uriDestDataType;
                string sourceDataInfoKey = GetTransferString(DMLibDataType.URI, uriDestDataType, CopyMethod.ServiceSideAsyncCopy);

                uriSourceAdaptor.GenerateData(sourceDataInfos[sourceDataInfoKey]);
            }
        }
        private Dictionary <string, FileNode> PrepareSourceData(long fileSizeInB)
        {
            var sourceFileNodes = new Dictionary <string, FileNode>();
            var sourceDataInfos = new Dictionary <string, DMLibDataInfo>();

            // Prepare source data info
            foreach (DMLibTransferDirection direction in GetAllValidDirections())
            {
                string fileName = GetTransferFileName(direction);

                DMLibDataInfo sourceDataInfo;
                string        sourceDataInfoKey;
                if (direction.SourceType != DMLibDataType.URI)
                {
                    sourceDataInfoKey = direction.SourceType.ToString();
                }
                else
                {
                    sourceDataInfoKey = GetTransferFileName(direction);
                }

                if (sourceDataInfos.ContainsKey(sourceDataInfoKey))
                {
                    sourceDataInfo = sourceDataInfos[sourceDataInfoKey];
                }
                else
                {
                    sourceDataInfo = new DMLibDataInfo(string.Empty);
                    sourceDataInfos[sourceDataInfoKey] = sourceDataInfo;
                }

                DMLibDataHelper.AddOneFileInBytes(sourceDataInfo.RootNode, fileName, fileSizeInB);

                FileNode sourceFileNode = sourceDataInfo.RootNode.GetFileNode(fileName);
                sourceFileNodes.Add(fileName, sourceFileNode);
            }

            // Generate source data
            foreach (var pair in sourceDataInfos)
            {
                DMLibDataType sourceDataType;
                if (Enum.TryParse <DMLibDataType>(pair.Key, out sourceDataType))
                {
                    DataAdaptor <DMLibDataInfo> sourceAdaptor = GetSourceAdaptor(sourceDataType);
                    sourceAdaptor.Cleanup();
                    sourceAdaptor.CreateIfNotExists();

                    sourceAdaptor.GenerateData(pair.Value);
                }
            }

            // Generate source data for URI source separately since it's destination related
            DataAdaptor <DMLibDataInfo> uriSourceAdaptor = GetSourceAdaptor(DMLibDataType.URI);

            uriSourceAdaptor.Cleanup();
            uriSourceAdaptor.CreateIfNotExists();

            DMLibTestContext.SourceType = DMLibDataType.URI;
            DMLibTestContext.IsAsync    = true;

            DMLibDataType[] uriDestDataTypes = { DMLibDataType.CloudFile, DMLibDataType.BlockBlob, DMLibDataType.PageBlob, DMLibDataType.AppendBlob };
            foreach (DMLibDataType uriDestDataType in uriDestDataTypes)
            {
                DMLibTestContext.DestType = uriDestDataType;
                string sourceDataInfoKey = GetTransferFileName(DMLibDataType.URI, uriDestDataType, true);

                uriSourceAdaptor.GenerateData(sourceDataInfos[sourceDataInfoKey]);
            }

            // Clean up destination
            foreach (DMLibDataType destDataType in DataTypes)
            {
                if (destDataType != DMLibDataType.URI)
                {
                    DataAdaptor <DMLibDataInfo> destAdaptor = GetDestAdaptor(destDataType);
                    destAdaptor.Cleanup();
                    destAdaptor.CreateIfNotExists();
                }
            }

            return(sourceFileNodes);
        }