Skip to content

Instantly share code, notes, and snippets.

View k0stya's full-sized avatar

Kostiantyn Khomenko k0stya

View GitHub Profile
@k0stya
k0stya / GameScorer_Tests.cs
Created May 13, 2014 17:37
Tennis kata bootstrap
using NUnit.Framework;
namespace TennisKataBootstrap
{
[TestFixture]
public class GameScorer_Tests
{
[Test]
public void Score_should_return_love_love_when_players_have_played()
{
@k0stya
k0stya / gist:9674193
Last active August 29, 2015 13:57
selenium playground
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
namespace BEPlayGround1
{
public class Navigation
{
private LoginPage _loginPage;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
namespace UrlShortener.Tests
{
[TestClass]
public class UrlShortener_Tests
{
private Shortener _service;
private Mock<IShortenerEngine> _engine;
Param(
[parameter(Mandatory=$true)]
[alias("f")]
$FilePath,
[alias("b")]
$BuildTypeId,
[alias("s")]
$ServerUrl,
[parameter()]
[alias("o")]
@k0stya
k0stya / SpecFlowExt
Created May 15, 2013 18:20
SpecFlow CreateSimpleSet
namespace TechTalk.SpecFlow
{
public static class SpecFlowExt
{
public static IEnumerable<T> CreateSimpleSet<T>(this Table table, string colName = null)
{
if (table.Rows.Count == 0)
{
throw new ApplicationException("Input table is empty");
}
@k0stya
k0stya / AssemblyGenerator.cs
Created March 25, 2013 19:54
Generate assembly at runtime
using System;
using System.Reflection;
using System.Reflection.Emit;
namespace ConsoleApplication1
{
public class AssemblyGenerator
{
public static ModuleBuilder CreateModuleBuilder(Action<ModuleBuilder> buildTypes, string assemblyName)
{
@k0stya
k0stya / FalseWarning.cs
Last active December 14, 2015 08:48
Reshaper highlights n.Value saying that there is a possibility of InvalidOperationException.
using System.Linq;
namespace Nullable
{
public class Nullable_Test
{
public void SumNullableNumbers()
{
int?[] numbers = new int?[10];
int sum = numbers.Where(n => n.HasValue).Sum(n => n.Value);
[TestMethod]
public void $MethodUnderTest$_should_$EXPECTED_BEHAVIOR$()
{
// Arrange
$END$
// Act
// Assert
}
@k0stya
k0stya / Test doubles - Test-Specific Object - testing protected members.cs
Last active December 14, 2015 03:09
If the system under test (SUT) was not designed specifically to be testable, we may find that the test cannot get access to state that it must initialize or verify at some point in the test.
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
namespace TestDoubles.Examples.TestSpecificSubclass.ProtectedMember
{
[TestClass]
public class Player_Test
{
[TestMethod]
public void Should_be_able_to_roll_die_wtih_max_face_value()
@k0stya
k0stya / Test doubles - Fake.cs
Last active December 14, 2015 03:09
Replace a component that the system under test (SUT) depends on with a much lighter-weight implementation.
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace TestDoubles.Examples.Fake
{
[TestClass]
public class Invoice_Test
{
[TestMethod]