Skip to content
This repository has been archived by the owner on Dec 6, 2019. It is now read-only.

Commit

Permalink
New faceted search capabilities
Browse files Browse the repository at this point in the history
Deeper CI integration in many modules
Issue #303 - invalid feature reference in foundation layer
Issue #281 - locks on package.config on deploy
  • Loading branch information
Eldblom-zz committed Apr 24, 2017
1 parent 109f038 commit 540e59a
Show file tree
Hide file tree
Showing 61 changed files with 697 additions and 643 deletions.
7 changes: 4 additions & 3 deletions publishsettings.targets
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<publishUrl>http://habitat.dev.local</publishUrl>
</PropertyGroup>
<PropertyGroup>
<publishUrl>http://habitat.dev.local</publishUrl>
<ExcludeFilesFromDeployment>packages.config</ExcludeFilesFromDeployment>
</PropertyGroup>
</Project>
2 changes: 2 additions & 0 deletions src/Feature/Language/code/Controllers/LanguageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ namespace Sitecore.Feature.Language.Controllers
using System.Net;
using System.Web.Mvc;
using Sitecore.Feature.Language.Infrastructure.Pipelines;
using Sitecore.Foundation.SitecoreExtensions.Attributes;
using Sitecore.Pipelines;

public class LanguageController : Controller
{
[HttpPost]
[SkipAnalyticsTracking]
public JsonResult ChangeLanguage(string newLanguage, string currentLanguage)
{
var args = new ChangeLanguagePipelineArgs(currentLanguage, newLanguage);
Expand Down
4 changes: 0 additions & 4 deletions src/Feature/Maps/code/Controllers/MapsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ public class MapsController : Mvc.Controllers.SitecoreController
{
private readonly IMapPointRepository mapPointRepository;

public MapsController() : this(new MapPointRepository())
{
}

public MapsController(IMapPointRepository mapPointRepository)
{
this.mapPointRepository = mapPointRepository;
Expand Down
68 changes: 32 additions & 36 deletions src/Feature/Maps/code/Repositories/MapPointRepository.cs
Original file line number Diff line number Diff line change
@@ -1,46 +1,42 @@
namespace Sitecore.Feature.Maps.Repositories
{
using System;
using System.Collections.Generic;
using System.Linq;
using Models;
using Foundation.SitecoreExtensions.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using Models;

public class MapPointRepository : IMapPointRepository
{
private readonly Foundation.Indexing.Repositories.ISearchServiceRepository searchServiceRepository;

public MapPointRepository() : this(new Foundation.Indexing.Repositories.SearchServiceRepository(new Foundation.Indexing.Models.SearchSettingsBase { Templates = new[] { Templates.MapPoint.ID } }))
[Foundation.DependencyInjection.Service]
public class MapPointRepository : IMapPointRepository
{
}
private readonly Foundation.Indexing.Repositories.ISearchServiceRepository searchServiceRepository;

public MapPointRepository(Foundation.Indexing.Repositories.ISearchServiceRepository searchServiceRepository)
{
this.searchServiceRepository = searchServiceRepository;
}
public MapPointRepository(Foundation.Indexing.Repositories.ISearchServiceRepository searchServiceRepository)
{
this.searchServiceRepository = searchServiceRepository;
}

public IEnumerable<MapPoint> GetAll(Data.Items.Item contextItem)
{
if (contextItem == null)
{
throw new ArgumentNullException(nameof(contextItem));
}
if (contextItem.IsDerived(Templates.MapPoint.ID))
{
return new List<MapPoint>
{
new MapPoint(contextItem)
};
}
if (!contextItem.IsDerived(Templates.MapPointsFolder.ID))
{
throw new ArgumentException("Item must derive from MapPointsFolder or MapPoint", nameof(contextItem));
}
public IEnumerable<MapPoint> GetAll(Data.Items.Item contextItem)
{
if (contextItem == null)
{
throw new ArgumentNullException(nameof(contextItem));
}
if (Foundation.SitecoreExtensions.Extensions.ItemExtensions.IsDerived(contextItem, Templates.MapPoint.ID))
{
return new List<MapPoint>
{
new MapPoint(contextItem)
};
}
if (!Foundation.SitecoreExtensions.Extensions.ItemExtensions.IsDerived(contextItem, Templates.MapPointsFolder.ID))
{
throw new ArgumentException("Item must derive from MapPointsFolder or MapPoint", nameof(contextItem));
}

var searchService = this.searchServiceRepository.Get();
searchService.Settings.Root = contextItem;
var searchService = this.searchServiceRepository.Get(new Foundation.Indexing.Models.SearchSettingsBase { Templates = new[] { Templates.MapPoint.ID } });
searchService.Settings.Root = contextItem;

return searchService.FindAll().Results.Select(x => new MapPoint(x.Item));
return searchService.FindAll().Results.Select(x => new MapPoint(x.Item));
}
}
}
}
4 changes: 4 additions & 0 deletions src/Feature/Maps/code/Sitecore.Feature.Maps.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@
<Compile Include="Templates.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Foundation\DependencyInjection\code\Sitecore.Foundation.DependencyInjection.csproj">
<Project>{366148B7-2392-4F42-80D6-786B7A3682AE}</Project>
<Name>Sitecore.Foundation.DependencyInjection</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Foundation\Dictionary\code\Sitecore.Foundation.Dictionary.csproj">
<Project>{0D6BA4D8-C469-4AE9-9EBB-93BDF7D7E78F}</Project>
<Name>Sitecore.Foundation.Dictionary</Name>
Expand Down
8 changes: 0 additions & 8 deletions src/Feature/Maps/tests/MapsControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@

public class MapsControllerTests
{
[Theory]
[AutoDbData]
public void DefaultConstructor_ShouldNotThrow()
{
Action act = () => new MapsController();
act.ShouldNotThrow();
}

[Theory]
[AutoDbData]
public void Constructor_ShouldNotThrow(IMapPointRepository mapPointRepository)
Expand Down
121 changes: 42 additions & 79 deletions src/Feature/Maps/tests/MapsPointsRepositoryTests.cs
Original file line number Diff line number Diff line change
@@ -1,84 +1,47 @@
namespace Sitecore.Feature.Maps.Tests
{
using System;
using System.Linq;
using Data;
using FakeDb;
using FluentAssertions;
using NSubstitute;
using Ploeh.AutoFixture.AutoNSubstitute;
using Repositories;
using Xunit;

public class MapsPointsRepositoryTests
{
[Theory]
[Foundation.Testing.Attributes.AutoDbData]
public void GetAll_NullPassed_ShouldThrowArgumentNullException()
{
var repository = new MapPointRepository();
Action a = () => repository.GetAll(null);
a.ShouldThrow<ArgumentNullException>();
}

[Theory]
[Foundation.Testing.Attributes.AutoDbData]
public void GetAll_PointItemPassed_ShouldReturnSinglePoint(Db db)
{
var itemid = ID.NewID;
db.Add(new DbItem("point", itemid, Templates.MapPoint.ID)
{
{Templates.MapPoint.Fields.Name, "nameField"}
});
var repository = new MapPointRepository();
var actual = repository.GetAll(db.GetItem(itemid));
actual.Single().Name.Should().Be("nameField");
}


[Theory]
[Foundation.Testing.Attributes.AutoDbData]
public void GetAll_WrongItemPassed_ShouldThrowException([FakeDb.AutoFixture.Content] Data.Items.Item item)
{
var repository = new MapPointRepository();
Action a = () => repository.GetAll(item);
a.ShouldThrow<ArgumentException>();
}


[Theory]
[Foundation.Testing.Attributes.AutoDbData]
public void GetAll_PointFolderItemPassed_ShouldCallSearchService(Db db, [Substitute] Foundation.Indexing.Repositories.ISearchServiceRepository searchRepo, [Substitute] Foundation.Indexing.Services.SearchService service)
using System;
using System.Linq;
using Data;
using FakeDb;
using FluentAssertions;
using Ploeh.AutoFixture.Xunit2;
using Repositories;
using Xunit;

public class MapsPointsRepositoryTests
{
var itemid = ID.NewID;
db.Add(new DbItem("point", itemid, Templates.MapPointsFolder.ID));
searchRepo.Get().Returns(service);
var repository = new MapPointRepository(searchRepo);
repository.GetAll(db.GetItem(itemid));
service.FindAll().Received(1);
}


[Theory]
[Foundation.Testing.Attributes.AutoDbData]
public void GetAll_PointFolderItemPassed_ShouldReturnsItemsFromSearchService([FakeDb.AutoFixture.Content] Data.Items.Item[] items, Db db, [Substitute]Foundation.Indexing.Repositories.ISearchServiceRepository searchRepo, [Substitute] Foundation.Indexing.Services.SearchService service, Foundation.Indexing.Models.ISearchResults results, Foundation.Indexing.Models.ISearchResult result)
{
var itemid = ID.NewID;
db.Add(new DbItem("point", itemid, Templates.MapPointsFolder.ID));
searchRepo.Get().Returns(service);
service.FindAll().Returns(results);
var searchResutls = items.Select(x =>
{
var sr = Substitute.For<Foundation.Indexing.Models.ISearchResult>();
sr.Item.Returns(x);
return sr;
});

results.Results.Returns(searchResutls);

var repository = new MapPointRepository(searchRepo);
var actual = repository.GetAll(db.GetItem(itemid));
actual.Count().Should().Be(items.Length);
[Theory]
[Foundation.Testing.Attributes.AutoDbData]
public void GetAll_NullPassed_ShouldThrowArgumentNullException([Frozen] Foundation.Indexing.Repositories.ISearchServiceRepository searchServiceRepository)
{
var repository = new MapPointRepository(searchServiceRepository);
Action a = () => repository.GetAll(null);
a.ShouldThrow<ArgumentNullException>();
}

[Theory]
[Foundation.Testing.Attributes.AutoDbData]
public void GetAll_PointItemPassed_ShouldReturnSinglePoint(Db db, [Frozen] Foundation.Indexing.Repositories.ISearchServiceRepository searchServiceRepository)
{
var itemid = ID.NewID;
db.Add(new DbItem("point", itemid, Templates.MapPoint.ID)
{
{Templates.MapPoint.Fields.Name, "nameField"}
});
var repository = new MapPointRepository(searchServiceRepository);
var actual = repository.GetAll(db.GetItem(itemid));
actual.Single().Name.Should().Be("nameField");
}


[Theory]
[Foundation.Testing.Attributes.AutoDbData]
public void GetAll_WrongItemPassed_ShouldThrowException([FakeDb.AutoFixture.Content] Data.Items.Item item, [Frozen] Foundation.Indexing.Repositories.ISearchServiceRepository searchServiceRepository)
{
var repository = new MapPointRepository(searchServiceRepository);
Action a = () => repository.GetAll(item);
a.ShouldThrow<ArgumentException>();
}
}
}
}
7 changes: 4 additions & 3 deletions src/Feature/Media/code/Controllers/MediaFeatureController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@
using System.Web.Mvc;
using Sitecore.Feature.Media.Models;
using Sitecore.Foundation.SitecoreExtensions.Repositories;
using Sitecore.Mvc.Presentation;

//Should be MediaController but this clashes with Sitecore.Controllers.MediaController
//Should be MediaController but this clashes with Sitecore.Controllers.MediaController
public class MediaFeatureController : Controller
{
public ActionResult SectionMedia()
{
var renderingPropertiesRepository = new RenderingPropertiesRepository();
var mediamBackgroundModel = renderingPropertiesRepository.Get<MediaBackgroundRenderingModel>();
var mediamBackgroundModel = renderingPropertiesRepository.Get<MediaBackgroundRenderingModel>(RenderingContext.Current.Rendering);

return this.View(mediamBackgroundModel);
}

public ActionResult PageHeaderMedia()
{
var renderingPropertiesRepository = new RenderingPropertiesRepository();
var mediamBackgroundModel = renderingPropertiesRepository.Get<MediaBackgroundRenderingModel>();
var mediamBackgroundModel = renderingPropertiesRepository.Get<MediaBackgroundRenderingModel>(RenderingContext.Current.Rendering);

return this.View(mediamBackgroundModel);
}
Expand Down
9 changes: 4 additions & 5 deletions src/Feature/News/Tests/NewsControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ public class NewsControllerTests
{
[Theory]
[AutoDbData]
public void NewsList_ShouldReturnViewResult(Db db, string itemName, ID itemId, INewsRepositoryFactory factory)
public void NewsList_ShouldReturnViewResult(Db db, string itemName, ID itemId, INewsRepository repository)
{
//Arrange
var newsController = new NewsController();
var controller = new NewsController(factory);
var controller = new NewsController(repository);
db.Add(new DbItem(itemName, itemId, Templates.NewsFolder.ID));
var contextItem = db.GetItem(itemId);
var context = new RenderingContext();
Expand All @@ -39,10 +38,10 @@ public void NewsList_ShouldReturnViewResult(Db db, string itemName, ID itemId, I

[Theory]
[AutoDbData]
public void LatestNews_ShouldReturnViewResult(Db db, string itemName, ID itemId, INewsRepositoryFactory factory)
public void LatestNews_ShouldReturnViewResult(Db db, string itemName, ID itemId, INewsRepository repository)
{
//Arrange
var controller = new NewsController(factory);
var controller = new NewsController(repository);
db.Add(new DbItem(itemName, itemId, Templates.NewsFolder.ID));
var contextItem = db.GetItem(itemId);
var context = new RenderingContext();
Expand Down
47 changes: 0 additions & 47 deletions src/Feature/News/Tests/NewsRepositoryFactoryTests.cs

This file was deleted.

Loading

0 comments on commit 540e59a

Please sign in to comment.