Skip to content

Instantly share code, notes, and snippets.

View cardinal252's full-sized avatar

Nathanael Mann cardinal252

View GitHub Profile
@cardinal252
cardinal252 / gist:7b5ef23dca7902088dcd
Last active September 26, 2017 14:38
Mocking the Context on GlassController<T>
[TestFixture] // using NSubstitute, NUnit and Fluent Assertions
public class TypedGlassControllerTests
{
[Test]
public void GlassController_can_set_and_get_context()
{
// Arrange
StubClass classToReturn = new StubClass();
var testHarness = new SingleTypedGlassControllerTestHarness();
testHarness.SitecoreContext.GetCurrentItem<StubClass>().Returns(classToReturn);
@cardinal252
cardinal252 / gist:96df9505353e43cfd1ef
Last active September 26, 2017 14:38
Mocking the DataSource on a GlassController<TContext, TDataSource>
[TestFixture] // using NSubstitute, NUnit and Fluent Assertions
public class GlassControllerContextItemTests
{
[Test]
public void GlassController_can_set_and_get_datasource()
{
// Arrange
ID expectedId = new ID(Guid.NewGuid());
DataSourceStubClass classToReturn = new DataSourceStubClass();
var testHarness = new DifferentTypedGlassControllerTestHarness();
using Glass.Mapper.Sc;
using Glass.Mapper.Sc.Pipelines.Response;
using XXX.Common.IoC;
using XXX.Core.Sc.Abstractions.Context;
using Sitecore.Mvc.Pipelines.Response.GetModel;
namespace XXX.Web
{
public class LanguageAgnosticGetModelFromView : GetModelFromView
{