public void NoMatchingPublishedPoem_ExpectNullReturned() { //Arrange var poemList = new PoemBuilder().Default().BuildCollection(size: 2); poemList.FirstOrDefault().PublishedRevision = poemList.FirstOrDefault().PoemRevisions.FirstOrDefault(); poemList.Last().PublishedRevision = poemList.Last().PoemRevisions.FirstOrDefault(); //Act var testResult = ApplySpecificationToList(poemList, Guid.Empty); //Assert Assert.Null(testResult); }
public void MatchingPoemIsNotPublished_ExpectNullReturned() { //Arrange var poemList = new PoemBuilder().Default().BuildCollection(size: 2); poemList.FirstOrDefault().PublishedRevision = poemList.FirstOrDefault().PoemRevisions.FirstOrDefault(); var poemToGet = poemList.Last(); poemToGet.PublishedRevision = null; //Act var testResult = ApplySpecificationToList(poemList, poemToGet.Id); //Assert Assert.Null(testResult); }
public async void OnGet_DefaultPage_ReturnsPublishedPoemFromRepository() { //Arrange var client = _appFactory.CreateClient(); var poems = new PoemBuilder().Default().BuildCollection(size: 2); var publishedPoem = poems.Last(); var publishedRevision = publishedPoem.PoemRevisions.FirstOrDefault(); publishedPoem.PublishedRevision = publishedRevision; var nonPublishedPoem = poems.FirstOrDefault(); nonPublishedPoem.PublishedRevision = null; _appFactory.DbContext.AddRange(poems); _appFactory.DbContext.SaveChanges(); //Act var response = await client.GetAsync("/"); var pageContent = await ResponseHelper.GetDocumentAsync(response); var selectors = new SelectorHelper(pageContent, PageElements.IndexPageSelectors); var title = selectors.Get <IHtmlElement>((int)PageElements.IndexPageElementEnum.PoemTitle); var body = selectors.Get <IHtmlElement>((int)PageElements.IndexPageElementEnum.PoemBody); //Assert Assert.NotNull(title); Assert.NotNull(body); Assert.Equal(publishedRevision.Title, title.TextContent); Assert.Equal(publishedRevision.Body, body.TextContent); }
public void NoPublishedPoem_ExpectEmptyListReturned() { //Arrange var poemList = new PoemBuilder().Default().BuildCollection(size: 2); poemList.FirstOrDefault().PublishedRevision = null; poemList.Last().PublishedRevision = null; //Act var testResult = ApplySpecificationToList(poemList); //Assert Assert.Empty(testResult); }
public void HasPublishedPoem_ExpectPoemReturned() { //Arrange var poemList = new PoemBuilder().Default().BuildCollection(size: 2); poemList.FirstOrDefault().PublishedRevision = null; var publishedPoem = poemList.Last(); publishedPoem.PublishedRevision = publishedPoem.PoemRevisions.FirstOrDefault(); //Act var testResult = ApplySpecificationToList(poemList); var returnedPoem = testResult.Single(); //Assert Assert.Equal(publishedPoem.Id, returnedPoem.Id); Assert.Equal(publishedPoem.PublishedRevision.Title, returnedPoem.PublishedRevision.Title); }
public void HasPublishedPoem_ExpectPoemReturned() { //Arrange var poemList = new PoemBuilder().Default().BuildCollection(size: 2); poemList.FirstOrDefault().PublishedRevision = null; var matchingPoem = poemList.Last(); matchingPoem.PublishedRevision = matchingPoem.PoemRevisions.FirstOrDefault(); //Act var testResult = ApplySpecificationToList(poemList); //Assert Assert.NotNull(testResult); Assert.Equal(matchingPoem.Id, testResult.Id); Assert.Equal(matchingPoem.PublishedRevision.Id, testResult.PublishedRevision.Id); Assert.Equal(matchingPoem.PublishedRevision.Title, testResult.PublishedRevision.Title); Assert.Equal(matchingPoem.PublishedRevision.Body, testResult.PublishedRevision.Body); }
public void HasMultiplePoems_ExpectOnlyTheLatestPublishedPoemReturned() { //Arrange var poemList = new PoemBuilder().Default().BuildCollection(size: 2); var olderPoem = poemList.FirstOrDefault(); olderPoem.PublishedRevision = olderPoem.PoemRevisions.FirstOrDefault(); olderPoem.LastModifiedDateUTC = DateTime.UtcNow.AddDays(-2); var matchingPoem = poemList.Last(); matchingPoem.PublishedRevision = matchingPoem.PoemRevisions.FirstOrDefault(); matchingPoem.LastModifiedDateUTC = olderPoem.LastModifiedDateUTC.AddDays(1); //Act var testResult = ApplySpecificationToList(poemList); //Assert Assert.NotNull(testResult); Assert.Equal(matchingPoem.Id, testResult.Id); Assert.Equal(matchingPoem.PublishedRevision.Id, testResult.PublishedRevision.Id); Assert.Equal(matchingPoem.PublishedRevision.Title, testResult.PublishedRevision.Title); Assert.Equal(matchingPoem.PublishedRevision.Body, testResult.PublishedRevision.Body); }