Microsoft.Protocols.TestSuites.Common.Common.GetDefaultFolderServerId C# (CSharp) Method

GetDefaultFolderServerId() public static method

Get the server ID for the given default folder type in the actual FolderSyncResponse.
public static GetDefaultFolderServerId ( FolderSyncResponse folderSyncResponse, FolderType folderType, ITestSite site ) : string
folderSyncResponse FolderSyncResponse A FolderSyncResponse returned by previous ActiveSync FolderSync operation.
folderType FolderType Specify the default folder type.
site ITestSite An instance of interface ITestSite which provides logging, assertions, and adapters for test code onto its execution context.
return string
        public static string GetDefaultFolderServerId(FolderSyncResponse folderSyncResponse, FolderType folderType, ITestSite site)
        {
            site.Assert.IsNotNull(folderSyncResponse, "The FolderSyncResponse should not be null.");
            site.Assert.IsNotNull(folderSyncResponse.ResponseData, "The FolderSyncResponse.ResponseData should not be null.");
            site.Assert.IsNotNull(folderSyncResponse.ResponseData.Changes, "The FolderSyncResponse.ResponseData.Changes should not be null.");
            site.Assert.IsNotNull(folderSyncResponse.ResponseData.Changes.Add, "The FolderSyncResponse.ResponseData.Changes.Add should not be null.");

            string serverId = null;

            foreach (FolderSyncChangesAdd addResponse in folderSyncResponse.ResponseData.Changes.Add)
            {
                int type = (int)folderType;
                if (string.Equals(addResponse.Type, type.ToString(), StringComparison.CurrentCultureIgnoreCase))
                {
                    serverId = addResponse.ServerId;
                    break;
                }
            }

            return serverId;
        }
Common