This repository has been archived by the owner on Dec 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
109f038
commit 540e59a
Showing
61 changed files
with
697 additions
and
643 deletions.
There are no files selected for viewing
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
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> |
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
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
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
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)); | ||
} | ||
} | ||
} | ||
} |
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
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
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
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>(); | ||
} | ||
} | ||
} | ||
} |
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
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.