public void VisitorPictures_Add_Failed_Test() { var visitorPicturesRepository = new Data.Repositories.Fakes.StubIVisitorPictureRepository(); var target = new VisitorPicturesController(visitorPicturesRepository); var task = target.Add(null); Assert.IsTrue(task.Exception != null); Assert.IsTrue(task.Exception.InnerExceptions.Where(e => e.GetType() == typeof(ArgumentNullException)).Any()); }
public void VisitorPictures_Add_Test() { bool called = false; var visitorPicturesRepository = new Data.Repositories.Fakes.StubIVisitorPictureRepository(); var newVisitor = new VisitorPicture() { VisitorPictureId = 1, }; visitorPicturesRepository.AddAsyncVisitorPicture = (visitor) => { Assert.IsTrue(visitor.VisitorPictureId == newVisitor.VisitorPictureId); called = true; return(Task.FromResult(10)); }; var target = new VisitorPicturesController(visitorPicturesRepository); var task = target.Add(newVisitor); Assert.IsTrue(called); }