Beispiel #1
0
        private static void PrepareSingleObjectSourceData(long fileSizeInB)
        {
            foreach (DMLibTransferDirection direction in GetAllValidDirections())
            {
                string fileName          = GetTransferFileName(direction);
                string sourceDataInfoKey = GetSourceDataInfoKey(direction);

                DMLibDataInfo sourceDataInfo = GetSourceDataInfo(sourceDataInfoKey);

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

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

                expectedFileNodes.Add(fileName, sourceFileNode);
            }
        }
Beispiel #2
0
        private static void PrepareDirSourceData(long fileSizeInB)
        {
            foreach (DMLibTransferDirection direction in GetAllDirectoryValidDirections())
            {
                string dirName           = GetTransferDirName(direction);
                string fileName          = dirName;
                string sourceDataInfoKey = GetSourceDataInfoKey(direction);

                DMLibDataInfo sourceDataInfo = GetSourceDataInfo(sourceDataInfoKey);

                DirNode subDirNode = new DirNode(dirName);
                DMLibDataHelper.AddOneFileInBytes(subDirNode, fileName, fileSizeInB);

                sourceDataInfo.RootNode.AddDirNode(subDirNode);

                directoryNodes.Add(dirName, subDirNode);

                expectedFileNodes.Add(fileName, subDirNode.GetFileNode(fileName));
            }
        }
        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);
        }