Slide("L4", texts: [Text(), Text("Only the right side")]),
Slide("L3",texts:[Text("One"),Text()]),
]);
Assert.That(SlideDeckSpecValidator.Validate(deck,TEMPLATE,0,0),Is.Empty,"An empty text at the end takes no slot, so one text fits a layout with one.");
}
[Test]
publicvoidTextClearlyBeyondTheSlotIsSentBack()
{
// The text slot of L3 holds about 9 lines at 28 pt. A little more is accepted, since the
// template shrinks text which runs long; much more is not:
Assert.That(SlideDeckSpecValidator.Validate(newSlideDeckSpec("Mars",[tooLong]),TEMPLATE,0,0),Has.Some.Contains("Slide 1: text 1 needs about 11 lines, but only about 9 fit"));
Assert.That(SlideDeckSpecValidator.Validate(deck,TemplateWithSlides(),0,5,USES),Is.Empty,"Every template slide counts as a slide of the presentation, an imprint included.");
Assert.That(SlideDeckSpecValidator.Validate(deck,TemplateWithSlides(),0,4,USES),Has.Some.Contains("has 5 slides, but exactly 4 were asked for"));
Assert.That(SlideDeckSpecValidator.Validate(editedDeck,TemplateWithSlides(),0,0,USES),Has.Some.Contains("Slide 2 has a subtitle, but layout L2 has none"),"An edited slide has the slots of its template slide.");
Assert.That(SlideDeckSpecValidator.Validate(unordered,TemplateWithSlides(),0,0,USES),Has.Some.Contains("The template slides are out of order. Keep them in the order 1, 2, 3, 4"));
Assert.That(SlideDeckSpecValidator.Validate(imprintInBetween,TemplateWithSlides(),0,0,USES),Is.Empty,"An imprint is a template slide like any other, so a new slide may follow it.");
Assert.That(edited,Has.Some.Contains("Slide 1: text 1 needs about 8 lines, but only about 5 fit."),"Four points of two lines each overfill the half the slide leaves.");
Assert.That(written,Is.Empty,"On a slide written anew, the same points fit the whole slot.");
Assert.That(IssuesOf(Edit(1)with{Removals=["element 1","label 1"]}),Is.Empty,"Removing alone edits a slide.");
Assert.That(IssuesOf(Edit(1)with{Removals=["element 2"]}),Has.Some.Contains("Slide 1 removes \"element 2\", which template slide 1 does not have."));
Assert.That(IssuesOf(Edit(1)with{Removals=["picture 1"]}),Has.Some.Contains("Slide 1 removes \"picture 1\", which template slide 1 does not have."));
Assert.That(IssuesOf(Edit(1)with{Removals=["title"]}),Has.Some.Contains("Slide 1 removes the title of template slide 1."));
Assert.That(IssuesOf(Edit(1,texts:[Text("New news")])with{Removals=["text 1"]}),Has.Some.Contains("Slide 1 fills text 1 and removes it as well."));
Assert.That(IssuesOf(Edit(1)with{Removals=["element 1"]},Slide("L1")with{Removals=["element 1"]}),Has.Some.Contains("Slide 3 is a new slide, which has nothing to remove."));
Assert.That(SlideDeckSpecValidator.Validate(newSlideDeckSpec("Weekly",[Edit(1)with{Removals=["element 1"]},Keep(2)with{Removals=["element 1"]}]),template,0,0,uses),Has.Some.Contains("Slide 2 keeps template slide 2 unchanged, so it takes no content."));
Assert.That(IssuesOf(Edit(1,texts:[Text("Mars"),Text("Moon"),Text("Venus")],labels:["Near","Far","Farther"])),Is.Empty,"Every copy takes content like a slot.");
Assert.That(IssuesOf(Edit(1,texts:[Text("Mars"),Text("Moon"),Text("Venus"),Text("Jupiter")])),Has.Some.Contains("Slide 1 has 4 texts, but layout L1 has only 3."));
Assert.That(IssuesOf(Edit(1,texts:[Text("Mars"),Text(newstring('x',120))])),Has.Some.Contains("Slide 1: text 2 needs about 5 lines, but only about 3 fit."),"A copy holds what its size allows.");
Assert.That(IssuesOf(Edit(1,labels:["Near"])with{Removals=["label 4"]}),Has.Some.Contains("Slide 1 removes \"label 4\", which template slide 1 does not have."));
Assert.That(IssuesOf(Edit(1,texts:[Text("Mars"),Text("Moon")])with{Removals=["text 2"]}),Has.Some.Contains("Slide 1 fills text 2 and removes it as well."));
varfitting=newSlideDeckSpec("Mars",[Slide("L1","Mars"),Slide("L2","Why Mars",startsChapter:true),Slide("L3","Water",texts:[Text("Ice at the poles")])]);
vardeviating=newSlideDeckSpec("Mars",[Slide("L3","Mars"),Slide("L3","Why Mars",texts:[Text("Close to Earth")],startsChapter:true)]);
Assert.That(issues,Has.Some.Contains("Slide 1 is the title slide, but uses layout L3. The title slide uses layout L1."));
Assert.That(issues,Has.Some.Contains("Slide 2 starts a chapter, but uses layout L3. Chapters start with a slide on layout L2; put their content on the slides that follow."));
Assert.That(SlideDeckSpecValidator.Validate(deviating,TEMPLATE,0,0),Is.Empty,"Without choices, the model decides every layout.");
Assert.That(missing,Has.Some.Contains("The presentation has no slide on layout L4 for the table of contents, which lists the topics or chapters of the presentation without times. Add one right after the title slide."));
Assert.That(missing,Has.Some.Contains("The presentation has no slide on layout L6 for the imprint"));
Assert.That(SlideDeckSpecValidator.Validate(newSlideDeckSpec("Mars",[title,contents,imprint,content]),TEMPLATE,0,0,chosenLayouts:chosen),Has.Some.Contains("The imprint on layout L6 is not the last slide."));
Assert.That(SlideDeckSpecValidator.Validate(deck,TEMPLATE,0,0,maxMainPointsPerSlide:3),Is.Empty,"A sub-point belongs to its main point.");
Assert.That(SlideDeckSpecValidator.Validate(deck,TEMPLATE,0,0,maxMainPointsPerSlide:2),Has.Some.Contains("Slide 2 has 3 main points, but at most 2 per slide were asked for, all its texts together."),"The texts of a slide count together.");
Assert.That(SlideDeckSpecValidator.Validate(deck,TEMPLATE,0,0),Is.Empty,"Without a maximum, the model chooses.");
Assert.That(issues,Has.Some.Contains("Picture 2 of PICTURE_LIBRARY is on slides 2, 3. Use a picture of the library at most once; only icons may repeat."));
Assert.That(issues,Has.None.Contains("Picture 3 of PICTURE_LIBRARY"),"An icon may mark several slides.");
Assert.That(issues,Has.None.Contains("refers to picture"),"The numbers of the library follow those of the pictures for the slides.");
Assert.That(issues,Has.None.Contains("is on no slide"),"Only the pictures for the slides have to be used.");
newTestLayout("Picture with text",TestPlaceholder.Title(),TestPlaceholder.Text(1,newSlotBounds(838_200,1_825_625,5_150_000,4_351_338)),TestPlaceholder.Picture(20,newSlotBounds(6_200_000,1_825_625,5_150_000,3_500_000))));
// Both pictures come from the library, and the first one is an icon:
Assert.That(basis.Keys,Is.EquivalentTo(new[]{"template slide 1","L2","template slide 4"}),"An edited template slide fills the slots of its layout, a kept one does not.");
Assert.That(SlideDeckSpecValidator.StillFits(deck,TemplateWithSlides(),basis),Is.True,"The same file, read once more.");
Assert.That(SlideDeckSpecValidator.StillFits(deck,ChangedTemplateWithSlides(newLayoutAt:3),basis),Is.True,"A new layout at the end of the slide master leaves the IDs of the others alone.");
Assert.That(SlideDeckSpecValidator.StillFits(deck,ChangedTemplateWithSlides(newLayoutAt:1),basis),Is.False,"L2 is another layout now.");
Assert.That(SlideDeckSpecValidator.StillFits(deck,ChangedTemplateWithSlides(deletedSlide:3),basis),Is.False,"Template slide 3 is the imprint now.");
Assert.That(SlideDeckSpecValidator.StillFits(deck,ChangedTemplateWithSlides(deletedSlide:3),newDictionary<string,string>()),Is.False,"Without a basis, nothing is known to fit.");