Skip to content

Instantly share code, notes, and snippets.

@sshushliapin
sshushliapin / AutoSitecoreCustomizations
Created March 3, 2023 13:35
The list of AutoFixture customizations intended to simplify unit testing in Sitecore projects
namespace AutoSitecoreCustomizations
{
public class AutoNSubstituteDataAttribute : AutoDataAttribute
{
public AutoNSubstituteDataAttribute()
: base(() => new Fixture()
.Customize(new AutoNSubstituteCustomization())
.Customize(new DatabaseCustomization())
.Customize(new ItemCustomization())
.Customize(new FieldCustomization()))
using AutoFixture;
using AutoFixture.Xunit2;
using NSubstitute;
using Sitecore.Data;
using Sitecore.Data.Items;
using Sitecore.NSubstituteUtils;
using Xunit;
namespace SitecoreUnitTestingSamples
{
@sshushliapin
sshushliapin / SitecoreUnitTestingSamples.02-AxesTest
Last active December 29, 2019 22:57
SitecoreUnitTestingSamples.02-AxesTest
using System.Linq;
using AutoFixture;
using AutoFixture.Xunit2;
using NSubstitute;
using Sitecore.Data;
using Sitecore.Data.Items;
using Xunit;
namespace SitecoreUnitTestingSamples
{
@sshushliapin
sshushliapin / SitecoreUnitTestingSamples.FirstMock
Last active December 21, 2023 11:28
Switching from FakeDb to mocks
using AutoFixture;
using AutoFixture.Kernel;
using AutoFixture.Xunit2;
using NSubstitute;
using Sitecore.Data;
using Sitecore.Data.Items;
using Xunit;
namespace SitecoreUnitTestingSamples
{
@sshushliapin
sshushliapin / Blog: Installing Docker.md
Created November 21, 2019 15:18 — forked from Jaykul/Blog: Installing Docker.md
Docker in PowerShell on Windows 10

Using Docker on Windows 10 (AU)

There are a lot of good reasons to use Docker. Right now, my reason is that I need to work with PowerShell on Linux, and with Windows 10 anniversary update, Windows containers now support Nano Server as well (which is the other logical place to test the new open source PowerShell).

Currently, Docker supports running Linux images or Windows images in their container service, but not both in the same server, so to get both, we need to first install Docker using the installer, (which handles dependencies like requiring Hyper-V and Containers) and then install the most recent version of the Windows service separately, and configure them to run together.

Start by installing the Linux Container server

Here's a full explanation, but you could just [run the whole script](#file-install-d

@sshushliapin
sshushliapin / App.config
Last active January 26, 2017 07:24
Switching Link Manager
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<services>
<!--
See FakeDb issue #153 for details:
https://github.com/sergeyshushlyapin/Sitecore.FakeDb/issues/153
-->
<configurator type="Sitecore.FakeDb.FakeDbServicesConfigurator, Sitecore.FakeDb" />
</services>
</sitecore>
namespace FakeDbSamples
{
using System.Collections.Generic;
using System.Linq;
using NSubstitute;
using Ploeh.AutoFixture;
using Ploeh.AutoFixture.AutoNSubstitute;
using Ploeh.AutoFixture.Xunit2;
using Sitecore.Abstractions;
using Sitecore.Common;
@sshushliapin
sshushliapin / AutoFixtureGreeterSample.cs
Last active December 4, 2015 09:11
AutoFixture-based version of the Greeter class
namespace AutoFixtureSample
{
using System;
using NSubstitute;
using Ploeh.AutoFixture;
using Ploeh.AutoFixture.AutoNSubstitute;
using Ploeh.AutoFixture.Xunit2;
using Xunit;
/// <summary>
namespace FakeDbSamples
{
using NSubstitute;
using Ploeh.AutoFixture;
using Ploeh.AutoFixture.AutoNSubstitute;
using Ploeh.AutoFixture.Xunit2;
using Sitecore.Buckets.Managers;
using Sitecore.Data.Items;
using Sitecore.FakeDb.AutoFixture;
using Sitecore.FakeDb.Buckets;
@sshushliapin
sshushliapin / SwitchingLinkProviderSample.cs
Created September 23, 2015 07:28
Switching the LinkProvider with Sitecore.FakeDb, AutoFixture, xUnit and NSubstitute
namespace FakeDbSamples
{
using NSubstitute;
using Ploeh.AutoFixture;
using Ploeh.AutoFixture.AutoNSubstitute;
using Ploeh.AutoFixture.Xunit2;
using Sitecore.Data.Items;
using Sitecore.FakeDb.AutoFixture;
using Sitecore.Links;
using Xunit;