public async Task LoadLink_ManyReferencesAsync() { var actual = await _sut.LoadLink <ManyReferencesLinkedSource>().FromModelAsync( new ManyReferencesContent { Id = 1, SummaryImageId = "summary-image-id", AuthorImageId = "author-image-id", FavoriteImageIds = new [] { "one", "two" } } ); Assert.Collection( actual.FavoriteImages, image => { Assert.Equal("one", image.Id); Assert.Equal("alt-one", image.Alt); }, image => { Assert.Equal("two", image.Id); Assert.Equal("alt-two", image.Alt); } ); }
public async Task LoadLink_IntPie() { var actual = await _sut.LoadLink <IntPieLinkedSource>().ByIdAsync("2"); Assert.Equal("2", actual.Model.Id); Assert.Equal("Int32", actual.SummaryImage.Id); }
public async System.Threading.Tasks.Task LoadLink_NestedLinkedSourceAsync() { var actual = await _sut.LoadLink <NestedLinkedSources>().FromModelAsync( new NestedContents { Id = 1, AuthorIds = new List <string> { "a", "b" } } ); Assert.Collection( actual.Authors, author => { Assert.Equal("a", author.Model.Id); Assert.Equal(author.Model.SummaryImageId, author.SummaryImage.Id); }, author => { Assert.Equal("b", author.Model.Id); Assert.Equal(author.Model.SummaryImageId, author.SummaryImage.Id); } ); }
public async Task LoadLink_WithModel_ShouldLinkModel() { var actual = await _sut.LoadLink <PrimitiveLinkedSource>().FromModelAsync(1); Assert.Equal(1, actual.Model); Assert.Equal(1, actual.Media.Id); }
public async Task LoadLinkByIdAsync() { var actual = await _sut.LoadLink <PersonLinkedSource>().ByIdAsync("one"); var expected = GetExpectedPersonLinkedSource("one"); actual.Should().BeEquivalentTo(expected); }
public async System.Threading.Tasks.Task LoadLink_ImagesFromDeclinaisonUrlAsync() { var actual = await _sut.LoadLink <WithImageLinkedSource>().FromModelAsync( new WithImage { Id = "1", ImageUrl = "a-1x1" } ); Assert.Contains("a-1x1", actual.Image.Ratios.Select(r => r.Url)); }
public async System.Threading.Tasks.Task LoadLink_SingleReferenceAsync() { var actual = await _sut.LoadLink <SingleReferenceLinkedSource>().FromModelAsync( new SingleReferenceContent { Id = "1", SummaryImageId = "a" } ); Assert.Equal("a", actual.SummaryImage.Id); }
public async System.Threading.Tasks.Task LoadLink_WithContextualization_ShouldLinkOverriddenImageAsync() { var actual = await _sut.LoadLink <PersonContextualizedLinkedSource>().ByIdAsync( "32", linkedSource => linkedSource.Contextualization = new PersonContextualization { Id = "32", Name = null, SummaryImageId = "overriden-image" } ); Assert.Equal("overriden-image", actual.Contextualization?.SummaryImageId); Assert.Equal("overriden-image", actual.SummaryImage.Id); }
public async System.Threading.Tasks.Task LoadLink_NestedLinkedSourceAsync() { var actual = await _sut.LoadLink <NestedLinkedSource>().FromModelAsync( new NestedContent { Id = 1, AuthorDetailId = "32", ClientSummaryId = "33" } ); Assert.Equal("32", actual.AuthorDetail.Model.Id); Assert.Equal(actual.AuthorDetail.Model.SummaryImageId, actual.AuthorDetail.SummaryImage.Id); Assert.Equal("33", actual.ClientSummary.Id); }
public async System.Threading.Tasks.Task LoadLink_WithContextualization_ShouldLinkOverriddenImageAsync() { var actual = await _sut.LoadLink <WithContextualizedReferenceLinkedSource>().FromModelAsync( new WithContextualizedReference { Id = "1", PersonContextualization = new PersonContextualization { Id = "32", Name = "Altered named", SummaryImageId = "overriden-image" } } ); Assert.Equal("overriden-image", actual.Person.Contextualization.SummaryImageId); Assert.Equal("overriden-image", actual.Person.SummaryImage.Id); }
public async Task LoadLink_WithContextualization_ShouldLinkOverriddenImage() { var model = new WithContextualizedReference { Id = "1", PersonContextualization = new PersonContextualization { Id = "32", Name = "Altered named", SummaryImageId = "overriden-image" } }; var actual = await _sut.LoadLink <WithContextualizedReferenceLinkedSource>().FromModelAsync(model); Assert.Same(model.PersonContextualization, actual.Person.Contextualization); Assert.Equal(model.PersonContextualization.Id, actual.Person.Model.Id); Assert.Same(model.PersonContextualization.SummaryImageId, actual.Person.SummaryImage.Id); }
public async System.Threading.Tasks.Task LoadLink_WithOverriddenLoadLinkExpression_ShouldUseOverriddenLoadLinkExpressionAsync() { var actual = await _sut.LoadLink <SingleReferenceLinkedSource>().FromModelAsync( new SingleReferenceContent { Id = "1", SummaryImageId = "a" } ); Assert.Equal("a-overridden", actual.SummaryImage.Id); }
public async Task LoadLink_SubLinkedSources() { var actual = await _sut.LoadLink <SubContentsOwnerLinkedSource>().FromModelAsync( new SubContentsOwner { Id = "1", SubContents = new List <SubContentWithManySubSubContents> { new SubContentWithManySubSubContents { SubSubContents = new List <SubSubContent> { new SubSubContent { SummaryImageId = "a" }, new SubSubContent { SummaryImageId = "b" } } } }, SubSubContents = new List <SubSubContent> { new SubSubContent { SummaryImageId = "c" }, new SubSubContent { SummaryImageId = "d" } } } ); var linkedImagesIds = actual.SubContents.SelectMany(subContent => subContent.SubSubContents).Select(subSubContent => subSubContent.Model.SummaryImageId); Assert.Equal(new[] { "a", "b" }, linkedImagesIds); linkedImagesIds = actual.SubSubContents.Select(subSubContent => subSubContent.Model.SummaryImageId); Assert.Equal(new[] { "c", "d" }, linkedImagesIds); }
public async Task LoadLink_SubLinkedSource() { var actual = await _sut.LoadLink <SubContentOwnerLinkedSource>().FromModelAsync( new SubContentOwner { Id = "1", SubContent = new SubContent { SubSubContent = new SubSubContent { SummaryImageId = "a" } }, SubSubContent = new SubSubContent { SummaryImageId = "b" } } ); Assert.Equal("a", actual.SubContent.SubSubContent.SummaryImage.Id); Assert.Equal("b", actual.SubSubContent.SummaryImage.Id); }
public async System.Threading.Tasks.Task LoadLink_MultipleReferencesTypeTestsAsync() { var actual = await _sut.LoadLink <MultipleReferencesTypeLinkedSource>().FromModelAsync( new MultipleReferencesTypeContent { Id = 1, SummaryImageId = "a", AuthorId = "32" } ); Assert.Equal("a", actual.SummaryImage.Id); Assert.Equal("32", actual.Author.Id); }
public async Task LoadLink_WithContextualization_ShouldLinkOverriddenImage() { var actual = await _sut.LoadLink <LinkedSource>().FromModelAsync( new Model { Person = new Person { Id = "32", Name = "dont-care", SummaryImageId = "defaultSummaryImageId" }, PersonContextualization = new PersonContextualization { Id = "32", Name = "dont-care", SummaryImageId = "overriddenSummaryImageId" } } ); Assert.Equal("overriddenSummaryImageId", actual.Person.Contextualization.SummaryImageId); Assert.Equal("overriddenSummaryImageId", actual.Person.SummaryImage.Id); }
public async Task LoadLink_WithModel_ShouldLinkModel() { var actual = await _sut.LoadLink <SingleReferenceLinkedSource>().FromModelAsync( new SingleReferenceContent { Id = "1", SummaryImageId = "a" } ); Assert.Equal("1", actual.Model.Id); Assert.Equal("a", actual.SummaryImage.Id); }