This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Web.Mvc; | |
| public class HomeController : Controller | |
| { | |
| public ActionResult Index() | |
| { | |
| if (User.Identity.IsAuthenticated) | |
| ViewBag.Message = "User = " + User.Identity.Name; | |
| else | |
| ViewBag.Message = "AnonymousID = " + Request.AnonymousID; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Poll-Website([string]$uri){ | |
| $status = "" | |
| $retryCount = 0; | |
| while($status -ne "OK" -and $retryCount -le 5){ | |
| try{ | |
| $status = (Invoke-WebRequest -Uri $uri).StatusDescription | |
| Write-Host $status | |
| } | |
| catch | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class FakeControllerContext : ControllerContext | |
| { | |
| public FakeControllerContext(IController controller) | |
| : this(controller, null, null, null, null, null, null) | |
| { | |
| } | |
| public FakeControllerContext(IController controller, HttpCookieCollection cookies) | |
| : this(controller, null, null, null, null, cookies, null) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @using (Html.BeginForm()) | |
| { | |
| @Html.TextArea("content") | |
| <input type="submit" value="Send it!" /> | |
| } | |
| @if (ViewBag.SentMessage != null) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// <reference path="~/Scripts/ThirdParty/knockout-2.1.0.debug.js" /> | |
| /// <reference path="~/Scripts/ThirdParty/moment.js" /> | |
| function YearSelector(earliestDate, latestDate) { | |
| var self = this; | |
| self.earliestDate = earliestDate; | |
| self.latestDate = latestDate; | |
| var getYears = function () { | |
| var years = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #32 bit path - "hklm:\software\microsoft\windows\currentversion\uninstall" | |
| $regInstallPath = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\" | |
| $installed = gci $regInstallPath | | |
| foreach { gp $_.PSPath } | | |
| select DisplayVersion,InstallDate,ModifyPath,Publisher,UninstallString,Language,DisplayName | | |
| where { ($_.DisplayName -ne $null) -and ($_.DisplayName -ne "") } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Main() | |
| { | |
| WorkItemReporter.GetTestCoverageReport(typeof(MyTest).Assembly).Dump(); | |
| } | |
| // Define other methods and classes here | |
| [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] | |
| public class WorkItemAttribute : Attribute | |
| { | |
| public WorkItemAttribute(WorkItemType workItemType, string id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Will need some rework and some decent test runs. IDeally generate the start of the csv too. | |
| public class PageFormTestInput<T> where T : new() | |
| { | |
| private const string isFormValidFieldName = "IsFormValid"; | |
| private readonly dynamic input; | |
| public PageFormTestInput(dynamic input) | |
| { | |
| this.input = input; | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Dynamic; | |
| using System.Collections.Generic; | |
| using System.Collections; | |
| using System.IO; | |
| using Xunit; | |
| namespace YourNamespace | |
| { | |
| public class DynamicCsv : DynamicObject |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class PesonalDetailsFixture | |
| { | |
| [Fact] | |
| public void RequiredPropertiesAreMarkedAsSo() | |
| { | |
| PropertyOn<PersonalData, string>(x => x.Title).Has<RequiredAttribute>(); | |
| PropertyOn<PersonalData, string>(x => x.FirstName).Has<RequiredAttribute>(); | |
| PropertyOn<PersonalData, string>(x => x.LastName).Has<RequiredAttribute>(); | |
| PropertyOn<PersonalData, DateTime>(x => x.DateOfBirth).Has<RequiredAttribute>(); | |
| PropertyOn<PersonalData, string>(x => x.Email).Has<RequiredAttribute>(); |