/// <summary> /// Build a new <see cref="ILoadLinkProtocol"/> and apply the <paramref name="conventions"/> to the specified <paramref name="types"/>. /// </summary> public static void ApplyConventions( this LoadLinkProtocolBuilder loadLinkProtocolBuilder, IList <Type> types, IList <ILoadLinkExpressionConvention> conventions) { if (loadLinkProtocolBuilder == null) { throw new ArgumentNullException(nameof(loadLinkProtocolBuilder)); } if (types == null) { throw new ArgumentNullException(nameof(types)); } if (conventions == null) { throw new ArgumentNullException(nameof(conventions)); } EnsureConventionNamesAreUnique(conventions); var matches = new FindAllConventionMatchesQuery(types, conventions).Execute(); var command = new ApplyLoadLinkConventionCommand(loadLinkProtocolBuilder, matches); command.Execute(); }
public void LoadLink_WithDiscriminantDuplicate_ShouldThrow() { var loadLinkProtocolBuilder = new LoadLinkProtocolBuilder(); Action act = () => loadLinkProtocolBuilder.For <PolymorphicSubLinkedSourceTests.LinkedSource>() .LoadLinkPolymorphic( linkedSource => linkedSource.Model.Target, linkedSource => linkedSource.Target, link => link.Type, includes => includes.Include <PolymorphicSubLinkedSourceTests.WebPageReferenceLinkedSource>().AsNestedLinkedSourceFromModel( "web-page", link => new PolymorphicSubLinkedSourceTests.WebPageReference() ) .Include <PolymorphicSubLinkedSourceTests.WebPageReferenceLinkedSource>().AsNestedLinkedSourceFromModel( "web-page", link => new PolymorphicSubLinkedSourceTests.WebPageReference() ) ); var ex = Assert.Throws <ArgumentException>(act); Assert.Contains("LinkedSource/Target", ex.Message); Assert.Contains("web-page", ex.Message); }
public ApplyLoadLinkConventionCommand(LoadLinkProtocolBuilder loadLinkProtocolBuilder, List <ConventionMatch> matches) { _loadLinkProtocolBuilder = loadLinkProtocolBuilder; _matches = matches; }
public LoadTests() { _referenceLoaderStub = new ReferenceLoaderStub(); _sut = new LoadLinkProtocolBuilder().Build(() => _referenceLoaderStub); }