Skip to content

Instantly share code, notes, and snippets.

@safestudent
safestudent / azure-pipelines.yml
Last active September 12, 2019 09:29
FSTA YAML
resources:
# The 'repo' section defines the code repository (self means 'this one' i.e. SprintTracker)
- repo: self
# The 'queue' section defines the machine on which we'll run our code and what are the tools we'll need to run the tests
queue:
# We'll use a standard machine that Azure provides for free with Visual Studio 2017
name: Hosted Windows 2019 with VS2019
# This just checks that the following software is installed on our 'Hosted VS2017' machine, as we need it to run our tests.
@safestudent
safestudent / Statistics.cs
Created December 4, 2018 12:19
GetAveragePoints Method
public object GetAveragePoints(SprintTrackerWebContext context)
{
// Create an empty list to store the points.
List<int> points = new List<int>();
// Get the points from each sprint in the database and add them to the list.
context.Sprint.ToList().ForEach(x => points.Add(x.ActualPoints));
// Check to see if the `points` list has any data in it
if (points.Any())
@safestudent
safestudent / AverageActualPointsModelTest.cs
Created December 4, 2018 12:18
AverageActualPointsModelTest
public void EmptyList()
{
// ARRANGE
// Initialise the Statistics class
Statistics stats = new Statistics();
// Set up 'in memory' database (can’t mock a context)
var options = new
DbContextOptionsBuilder<SprintTrackerWebContext>()
.UseInMemoryDatabase(databaseName: "Add_writes_to_database").Options;
@safestudent
safestudent / SprintTrackerWebContextTest.cs
Created December 4, 2018 12:17
SprintTrackerWebContextTest.cs
using Microsoft.EntityFrameworkCore;
using SprintTracker.Web;
using SprintTracker.Web.Models;
using System.Linq;
using Xunit;
namespace SprintTracker.Tests
{
public class SprintTrackerWebContextTest
{
@safestudent
safestudent / SprintsControllerTest.cs
Created December 4, 2018 12:15
SprintsControllerTest
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using SprintTracker.Web.Controllers;
using SprintTracker.Web.Models;
using System.Threading.Tasks;
using Xunit;
namespace SprintTracker.Tests
{
public class SprintsControllerTest
{
@safestudent
safestudent / NuGet Console
Last active March 14, 2019 13:55
SpecFlow Report Generation
specflow.exe nunitexecutionreport --ProjectFile ToolsList.AcceptanceTests\ToolsList.AcceptanceTests.csproj --xmlTestResult TestResult.xml
@safestudent
safestudent / NuGet Console
Last active March 14, 2019 13:54
Generate Report
nunit3-console.exe --labels=All --out=TestResult.txt “--result=TestResult.xml;format=nunit2” ToolsList.AcceptanceTests\bin\Debug\ToolsList.AcceptanceTests.dll
@safestudent
safestudent / azure-pipelines.yml
Last active September 12, 2019 09:30
CI Pipeline MAT DotNet
resources:
# The 'repo' section defines the code repository (self means 'this one' i.e. ToolsList)
- repo: self
# The 'queue' section defines the machine on which we'll run our code and what are the tools we'll need to run the tests
queue:
# We'll use a standard machine that Azure provides for free. It comes pre-installed with Visual Studio 2017
name: Hosted Windows 2019 with VS2019
@safestudent
safestudent / Driver.cs
Created September 19, 2018 16:49
Screenshots
public static string GetPathToMyDocuments()
{
// return the absolute path to the MyDocuments folder on your computer
return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
}
// you need to pass through the filename you want to call your screenshot
public static void FullScreenScreenshot(string fileName)
{
// take the screenshot
@safestudent
safestudent / Driver.cs
Created September 19, 2018 16:46
Wait for Element
public static IWebElement WaitForElement(By locator)
{
// Here we set the timeout as 5 second, 0 minutes and 0 hours
WebDriverWait wait = new WebDriverWait(Browser, new TimeSpan(0, 0, 5));
// Here we set the `Until` condition as until the browser finds the element. If it find the element in 5 seconds, it will return it.
return wait.Until(Browser => Browser.FindElement(locator));
}