Example #1
0
        public void Should_ThrowArgumentNullException_When_ArgumentIsNull()
        {
            global::System.Threading.Tasks.Task test = null;
            Assert.Throws <ArgumentNullException>(() => new PluralsightNodeParser(null, null));

            var sut = new PluralsightNodeParser(SiteUrl, _nodeSelector);

            Assert.Throws <ArgumentNullException>(() => sut.ParseCategoryNode(null));
            Assert.Throws <ArgumentNullException>(() => sut.ParseCategoryIdInHtmlDocument(null));
            Assert.Throws <ArgumentNullException>(() => sut.ParseSketchNode(null));
            Assert.Throws <ArgumentNullException>(() => sut.ParseCourseInfo(null));
            Assert.Throws <ArgumentNullException>(() => sut.ParseAuthor(null));
            Assert.Throws <ArgumentNullException>(() => sut.ParseAuthorFullName(null));
            Assert.Throws <ArgumentNullException>(() => sut.IsCoAuthorNode(null));
            Assert.Throws <ArgumentNullException>(() => sut.ParseCoAuthors(null));
            Assert.Throws <ArgumentNullException>(() => sut.ParseCourseLevel(null));
            Assert.Throws <ArgumentNullException>(() => sut.ParseCourseRating(null));
            Assert.Throws <ArgumentNullException>(() => sut.ParseCourseDuration(null));
            Assert.Throws <ArgumentNullException>(() => sut.ParseCourseReleaseDate(null));
        }
Example #2
0
 /// <summary>
 /// Overrides OnDefault method in the generated cmdlets.
 /// </summary>
 /// <param name="cmdlet">The calling <see cref="PSCmdlet"/></param>
 /// <param name="responseMessage">The HTTP response message from the service.</param>
 /// <param name="returnNow">Determines whether the caller should return after OverrideOnDefault is called, or not. </param>
 public static void OverrideOnDefault(this PSCmdlet cmdlet, global::System.Net.Http.HttpResponseMessage responseMessage, ref global::System.Threading.Tasks.Task <bool> returnNow)
 {
     if (responseMessage.IsSuccessStatusCode)
     {
         if (cmdlet.MyInvocation?.BoundParameters?.ContainsKey("PassThru") == true)
         {
             cmdlet.WriteObject(true);
         }
         returnNow = global::System.Threading.Tasks.Task <bool> .FromResult(true);
     }
 }
        /// <summary>
        /// <c>overrideOnOk</c> will be called before the regular onOk has been processed, allowing customization of what happens
        /// on that response. Implement this method in a partial class to enable this behavior
        /// </summary>
        /// <param name="responseMessage">the raw response message as an global::System.Net.Http.HttpResponseMessage.</param>
        /// <param name="response">the body result as a <see cref="Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.Api20210901.IContainerExecResponse"
        /// /> from the remote call</param>
        /// <param name="returnNow">/// Determines if the rest of the onOk method should be processed, or if the method should return
        /// immediately (set to true to skip further processing )</param>
        partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task <Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.Api20210901.IContainerExecResponse> response, ref global::System.Threading.Tasks.Task <bool> returnNow)
        {
            var containerExecResponse = response.ConfigureAwait(false).GetAwaiter().GetResult();

            socket = new System.Net.WebSockets.ClientWebSocket();
            // Connect websocket
            socket.ConnectAsync(new System.Uri(containerExecResponse.WebSocketUri), _cancellationTokenSource.Token).ConfigureAwait(false).GetAwaiter().GetResult();
            socket.SendAsync(new ArraySegment <byte>(Encoding.UTF8.GetBytes(containerExecResponse.Password)), WebSocketMessageType.Text, true, _cancellationTokenSource.Token).ConfigureAwait(false).GetAwaiter().GetResult();

            var receiver = PullResponse();
            var sender   = PushCommand();

            Task.WaitAll(sender, receiver);
            returnNow = global::System.Threading.Tasks.Task.FromResult(true);
        }
Example #4
0
 public static global::Windows.Foundation.IAsyncOperation <TResult> AsAsyncOperation <TResult>(this global::System.Threading.Tasks.Task <TResult> source)
 {
     throw null;
 }
Example #5
0
 public static global::Windows.Foundation.IAsyncAction AsAsyncAction(this global::System.Threading.Tasks.Task source)
 {
     throw null;
 }
Example #6
0
 public static global::Windows.Foundation.IAsyncOperation <TResult> AsAsyncOperation <TResult>(this global::System.Threading.Tasks.Task <TResult> source)
 {
     return(default(global::Windows.Foundation.IAsyncOperation <TResult>));
 }
Example #7
0
 public static global::Windows.Foundation.IAsyncAction AsAsyncAction(this global::System.Threading.Tasks.Task source)
 {
     return(default(global::Windows.Foundation.IAsyncAction));
 }
        partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task <global::System.IO.Stream> response, ref global::System.Threading.Tasks.Task <bool> returnNow)
        {
            global::System.Collections.ObjectModel.Collection <global::System.String> paths;
            try {
                paths = this.SessionState.Path.GetResolvedProviderPathFromPSPath(OutFile, out var provider);
                if (provider.Name != "FileSystem" || paths.Count == 0)
                {
                    ThrowTerminatingError(new System.Management.Automation.ErrorRecord(new global::System.Exception("Invalid output path."), string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, OutFile));
                }
                if (paths.Count > 1)
                {
                    ThrowTerminatingError(new System.Management.Automation.ErrorRecord(new global::System.Exception("Multiple output paths not allowed."), string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, OutFile));
                }
            } catch (global::System.Management.Automation.ItemNotFoundException) {
                paths = new global::System.Collections.ObjectModel.Collection <global::System.String>();
                paths.Add(OutFile);
            }
            var path = global::System.IO.Path.GetFullPath(paths[0]);

            using (var stream = response.GetAwaiter().GetResult())
            {
                using (var fileStream = global::System.IO.File.OpenWrite(path))
                {
                    stream.CopyTo(fileStream);
                }
                if (!path.Equals(paths[0]))
                {
                    WriteObject($"OutFile: {path}");
                }
            }
            if (true == MyInvocation?.BoundParameters?.ContainsKey("PassThru"))
            {
                WriteObject(true);
            }
            returnNow = global::System.Threading.Tasks.Task.FromResult <bool>(true);
        }