Ejemplo n.º 1
0
        /// <summary>
        /// Use the partner operations to perform the test.
        /// </summary>
        /// <param name="test">Encapsulates a test to execute.</param>
        /// <param name="identity">Identity of the test being executed.</param>
        /// <returns>
        /// An instance of the <see cref="Task" /> class that represents the asynchronous operation.
        /// </returns>
        public async Task UsePartnerForAsync(Func <IPartner, Task> test, [CallerMemberName] string identity = null)
        {
            IPartnerCredentials credentials = new TestPartnerCredentials();

            await test(TestPartnerService.CreatePartnerOperations(credentials, httpMockHandler));

            if (httpMockHandler.Mode == HttpMockHandlerMode.Record)
            {
                httpMockHandler.Flush(identity);
            }
        }
        /// <summary>
        /// Creates a new instance of the object used to interface with Partner Center.
        /// </summary>
        /// <returns>An instance of the <see cref="PartnerOperations" /> class.</returns>
        public IPartner CreatePartnerOperations()
        {
            if (partnerOperations == null)
            {
                partnerOperations = TestPartnerService.CreatePartnerOperations(
                    credentials,
                    httpMockHandler);
            }

            return(partnerOperations);
        }
        /// <summary>
        /// Creates a new instance of the object used to interface with Partner Center.
        /// </summary>
        /// <param name="correlationId">The correlation identifier for the request context.</param>
        /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
        /// <returns>An instance of the <see cref="PartnerOperations" /> class.</returns>
        public virtual async Task <IPartner> CreatePartnerOperationsAsync(Guid correlationId = default, CancellationToken cancellationToken = default)
        {
            if (partnerOperations == null)
            {
                partnerOperations = TestPartnerService.CreatePartnerOperations(
                    credentials,
                    httpMockHandler);
            }

            await Task.CompletedTask.ConfigureAwait(false);

            return(partnerOperations);
        }
        /// <summary>
        /// Creates a new instance of the object used to interface with Partner Center.
        /// </summary>
        /// <returns>An instance of the <see cref="PartnerOperations" /> class.</returns>
        public virtual async Task <IPartner> CreatePartnerOperationsAsync()
        {
            if (partnerOperations == null)
            {
                partnerOperations = TestPartnerService.CreatePartnerOperations(
                    credentials,
                    httpMockHandler);
            }

            await Task.CompletedTask.ConfigureAwait(false);

            return(partnerOperations);
        }