Skip to content

Instantly share code, notes, and snippets.

View hermanussen's full-sized avatar

Robin Hermanussen hermanussen

View GitHub Profile
<szfolders>
<folder name="core" value="c:\somefolder\data\serialization\core\" />
<folder name="master" value="c:\somefolder\data\serialization\master\" />
<folder name="web" value="c:\somefolder\data\serialization\web\" />
</szfolders>
[TestCase]
public void TestCombined()
{
using (Db db = new Db()
{
new DsDbTemplate(
"/sitecore/templates/Sample/Sample Item"),
new DsDbItem("/sitecore/content/home", true)
{
new DbItem("Child")
// PLATFORM MODE IS ON - please check the CompiledDomainModel settings if this was unintentional
//
// Please use the following url and change it to your needs:
// http://sitecoredemo/sitecore/shell/Applications/CompiledDomainModel/CodeGenerator.aspx?platformsets=<PIPE_SEPARATED_SET_NAMES>
//
// Use one or more of the following names to generate for the part of the platform you need (exclude the brackets):
// [Core] (should be used in a project that all other projects have a dependency with)
// [PlatformTemplatesSet] (domain objects)
// [SomeProjectTemplatesSet] (domain objects)
// [PlatformFixedPaths] (fixed paths)
<system.web.webPages.razor>
...
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
...
<add namespace="Sitecore.Mvc" />
<add namespace="UnitTestingDemo.Website.Util"/>
</namespaces>
</pages>
using System;
using System.Linq.Expressions;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Web;
using Sitecore.Collections;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
using Sitecore.Mvc.Helpers;
using UnitTestingDemo.Website.Domain;
<pipelines>
<mvc.getModel>
<processor
patch:before="*[@type='Sitecore.Mvc.Pipelines.Response.GetModel.CreateDefaultRenderingModel, Sitecore.Mvc']"
type="UnitTestingDemo.Website.Pipelines.CreateTypedRenderingModel, UnitTestingDemo.Website"/>
</mvc.getModel>
</pipelines>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Sitecore.Mvc.Pipelines.Response.GetModel;
using Sitecore.Mvc.Presentation;
using UnitTestingDemo.Website.Domain;
using UnitTestingDemo.Website.Models;
namespace UnitTestingDemo.Website.Pipelines
using Sitecore.Mvc.Presentation;
using UnitTestingDemo.Website.Domain;
namespace UnitTestingDemo.Website.Models
{
/// <summary>
/// Use this interface as a model for a Razor view if you want to use a CDM wrapper from the view.
/// </summary>
/// <typeparam name="T">The type of the wrapper that the model needs to support</typeparam>
public interface IRenderingModel<out T> : IRenderingModel where T : ItemWrapper
@model UnitTestingDemo.Website.Models.IRenderingModel<UnitTestingDemo.Website.Domain.DomainModel.Page>
<h1>@Html.Sitecore().Field(() => Model.Item.Title)</h1>
@Html.Sitecore().Field(() => Model.Item.TextContent)
[TestMethod]
[Description("Tests the import of an image into the media library")]
public void TestImageImport()
{
string sampleImage = ConfigurationManager.AppSettings["sampleimage"];
SampleSitecoreLogic.ImportImage(sampleImage);
// Get the imported media item
MediaItem imported = new MediaItem(Sitecore.Context.Database.GetItem("/sitecore/media library/Cdm"));