Example #1
0
        internal async Task <PnPContext> CloneForTestingAsync(PnPContext source, Guid groupId, int id)
        {
            PnPContext clonedContext = PrepareClonedContext();

            clonedContext.CloneCount = source.CloneCount + 13;

            if (source.Mode == TestMode.Mock)
            {
                clonedContext.SetMockMode(id, source.TestName, source.TestFilePath, source.GenerateTestMockingDebugFiles, source.TestUris);
            }
            else
            {
                clonedContext.SetRecordingMode(id, source.TestName, source.TestFilePath, source.GenerateTestMockingDebugFiles, source.TestUris);
            }

            await InitializeClonedContextAsync(groupId, clonedContext).ConfigureAwait(false);

            return(clonedContext);
        }
Example #2
0
        internal async Task <PnPContext> CloneForTestingAsync(PnPContext source, Uri uri, string name, int id)
        {
            if (uri == null)
            {
                if (!string.IsNullOrEmpty(name))
                {
                    if (string.IsNullOrEmpty(name))
                    {
                        throw new ArgumentException(string.Format(PnPCoreResources.Exception_PnPContext_EmptyConfiguration, nameof(name)));
                    }

                    var configuration = ContextOptions.Configurations.FirstOrDefault(c => c.Name == name);
                    if (configuration == null)
                    {
                        throw new ArgumentException(string.Format(PnPCoreResources.Exception_PnPContext_InvalidConfiguration, name));
                    }
                    uri = configuration.SiteUrl;
                }
                else if (uri == null)
                {
                    uri = Uri;
                }
            }

            PnPContext clonedContext = CreateClonedContext(uri);

            if (source.Mode == TestMode.Mock)
            {
                clonedContext.SetMockMode(id, source.TestName, source.TestFilePath, source.GenerateTestMockingDebugFiles, source.TestUris);
            }
            else
            {
                clonedContext.SetRecordingMode(id, source.TestName, source.TestFilePath, source.GenerateTestMockingDebugFiles, source.TestUris);
            }

            await InitializeClonedContextAsync(uri, clonedContext).ConfigureAwait(false);

            return(clonedContext);
        }