Skip to content

Instantly share code, notes, and snippets.

do {
write-host Installing powershell 4.0... -ForegroundColor Gray
start-sleep -s 10
} while ((get-process | where { $_.ProcessName -eq "wusa" }) -ne $Null)
@johnmmoss
johnmmoss / dotnetcore-test-modelstate.cs
Created October 16, 2017 12:49
Unit Test the model state in dotnet core
var controller = new CustomerController(_customerService.Object);
var newModel = new CreateModel();
var validationContext = new ValidationContext(newModel, null, null);
var validationResults = new List<ValidationResult>();
Validator.TryValidateObject(newModel, validationContext, validationResults, true);
foreach (var validationResult in validationResults)
{
controller.ModelState.AddModelError(validationResult.MemberNames.FirstOrDefault() ?? string.Empty, validationResult.ErrorMessage);
# Register a new Repository
Register-PSRepository
-Name PSRepository
-PackageManagementProvider NuGet
-InstallationPolicy Trusted
-Credential Get-Credential
-SourceLocation https://<project-name>.pkgs.visualstudio.com/_packaging/<repo-name>/nuget/v3/index.json
-PublishLocation https://<project-name>.pkgs.visualstudio.com/_packaging/<repo-name>/nuget/v3/index.json
function Say-Hello() {
write-host Hello! -ForegroundColour green
}
function Say-Goodbye() {
write-host Goodbye! -ForegroundColour red
}
New-ModuleManifest -Path "C:\Program Files\WindowsPowerShell\Modules\Greetings\Greetings.psd1"
-RootModule 'Greetings.psm1'
-Author 'John Moss'
# Add TFS Package Management Source for Nuget
nuget.exe sources add -name Powershell -source http://url/to/package/repo/index.json -username VSTS -password "pat-from-tfs" -storePasswordInClearText
# Register the PowershellGet source
Register-PSRepository -Name Powershell -SourceLocation http://url/to/package/repo/index.json -PackageManagementProvider NuGet -PublishLocation http://url/to/package/repo/index.json -InstallationPolicy Trusted -Credential Get-Credential
# Finally we can push the loaded module to our TFS Repository
Publish-Module -Name Greetings -Repository Powershell -NuGetApiKey "pat-from-tfs" -Credential Get-Credential
// CsvHelper.CsvReader:- https://joshclose.github.io/CsvHelper/
var result = new List<OrderRow>();
using (TextReader fileReader = File.OpenText(_fileName))
{
var csvReader = new CsvReader(fileReader);
csvReader.Configuration.HasHeaderRecord = false;
while (csvReader.Read())
{
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Install-Module vim-x64 -y
Install-Module -Name PowerShellForGitHub
Test-path $profile # if false then we create the profile file
$subscription_id_test = "<guid>"
$ScriptPath = Split-Path $MyInvocation.InvocationName
$templateFile = "$ScriptPath\WebApi\WebSite.json" # Sample Azure Template
$name = "TestWebApi"
$hostPlan = "F1" # Defined in the parameters in template
write-host Importing azure module -ForegroundColor gray
Import-Module -Name AzureRM
Feature: UserAdmin
In order to use the site
As an employee
I want to be able to register and login to the site
Scenario: A valid user can login to the site
Given I am a valid user of the site
And I have navigated to the login page
And I have entered a username of "johndoe" and a password of "Password1!"
When I click the create button