This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GlassLazy<T> : Lazy<T> | |
{ | |
public GlassLazy(Func<object> lazy) : base(() => (T)lazy()) | |
{ | |
} | |
public override string ToString() | |
{ | |
return Value.ToString(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
using xxx.App_Start; | |
using Glass.Mapper.Sc; | |
using Xunit; | |
namespace xxx.UnitTests | |
{ | |
public class GlassContextTests | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using Glass.Mapper.Sc.Configuration; | |
using Glass.Mapper.Sc.Configuration.Attributes; | |
using NUnit.Framework; | |
using Sitecore.Configuration; | |
using Sitecore.Data; | |
using Sitecore.Data.Items; | |
using Sitecore.Globalization; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyTypedController : GlassController<IContentItem> | |
{ | |
public ActionResult DisplayControl() | |
{ | |
return View(DataSource); // returns the view using the DataSource as the model of type IContentItem | |
} | |
} | |
public interface IContentItem | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestFixture] // using NSubstitute, NUnit and Fluent Assertions | |
public class GlassControllerLayoutItemTests | |
{ | |
[Test] | |
public void GlassController_can_set_and_get_layout_item_from_datasource() | |
{ | |
// Arrange | |
ID expectedId = new ID(Guid.NewGuid()); | |
StubClass classToReturn = new StubClass(); | |
var testHarness = new GlassControllerTestHarness(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestFixture] | |
public class GlassControllerHttpContextTests | |
{ | |
[Test] | |
public void GlassController_can_get_query_string_from_http_context_mock() | |
{ | |
// Arrange | |
var testHarness = new GlassControllerTestHarness(); | |
NameValueCollection nvc = new NameValueCollection(); | |
nvc.Add("fred", "flintstone"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestFixture] // using NSubstitute, NUnit and Fluent Assertions | |
public class GlassControllerContextItemTests | |
{ | |
[Test] | |
public void GlassController_can_set_and_get_context() | |
{ | |
// Arrange | |
StubClass classToReturn = new StubClass(); | |
var testHarness = new GlassControllerTestHarness(); | |
testHarness.SitecoreContext.GetCurrentItem<StubClass>().Returns(classToReturn); |
NewerOlder