[Test][Ignore] // TODO - another one of these cases where need to work out how to use the extension public void Post_ShouldRedirectToViewBookPage_WithUpdatedBooksId() { var model = new UpdateBookInputModel { Id = "chewingGum" }; var result = endpoint.Post(model); Func<ViewBookLinkModel, bool> destination = x => x.Id == model.Id; result.AssertWasRedirectedTo(destination); }
public void Post_GivenUpdateModel_ShouldCreateDtoAndPassToBookUpdater() { var model = new UpdateBookInputModel { Authors = new List<string> {"Jimmy", "Johnny", "Murray Walker"}.ToStringWrappers().ToList<StringWrapper>(), Genre = "genres/9", BookStatus = BookStatus.Reviewed, Title = "Updated title", Id = "books/444", Rating = 3, Description_BigText = "Updated description", }; endpoint.Post(model); UpdaterShouldHaveBeenCalledWithDtoMatching(model); }
public FubuContinuation Post(UpdateBookInputModel model) { var dto = new UpdateBookDto { Authors = model.Authors.ToStrings(), Status = model.BookStatus, Image = model.Image == null || model.Image.ContentLength == 0 ? null : FileUploader.GetBytes(model.Image), Genre = model.Genre, Id = model.Id, Title = model.Title, Rating = model.Rating, Description = model.Description_BigText, }; updater.Update(dto); return FubuContinuation.RedirectTo(new ViewBookLinkModel {Id = model.Id}); }
private void UpdaterShouldHaveBeenCalledWithDtoMatching(UpdateBookInputModel model) { updater.AssertWasCalled(x => x.Update(Arg<UpdateBookDto>.Is.Anything)); var dto = (UpdateBookDto) (updater.GetArgumentsForCallsMadeOn(x => x.Update(Arg<UpdateBookDto>.Is.Anything))[0][0]); HasMatchingAuthors(model, dto); Assert.AreEqual(dto.Description, model.Description_BigText); Assert.AreEqual(dto.Genre, model.Genre); Assert.AreEqual(dto.Id, model.Id); Assert.AreEqual(dto.Status, model.BookStatus); Assert.AreEqual(dto.Title, model.Title); Assert.AreEqual(dto.Rating, model.Rating); }
private static void HasMatchingAuthors(UpdateBookInputModel model, UpdateBookDto dto) { // TODO - move this logic into a list comparer - it has been implemented in the creater Assert.AreEqual(model.Authors.Count(), dto.Authors.Count()); var y = dto.Authors.ToList(); Assert.That(y.All(a => model.Authors.Any(x => a == x)), Is.True); }