public void GetAuthorByIdMustSucceed() { var repo = RepositoryFactory.CreateAuthorRepository(); var author = repo.GetAuthorById(ObjectMother.Instance.Authors.CliveCustler.Id); Assert.IsNotNull(author); Assert.IsTrue(ObjectMother.Instance.Authors.CliveCustler.Equals(author)); }
public void AddAuthorWithSuccess() { var repo = RepositoryFactory.CreateAuthorRepository(); var request = new AuthorBuilder().AuthorOne().BuildRequest(); var response = repo.AddAuthor(request); var found = Database.Authors.FirstOrDefault(auth => auth.Id == response.Id); Assert.AreEqual(response, found); }
public void IntrusiveTestThatDoesNotPersistChanges() { // Ensure that 'Distributed Transaction Coordinato' service is running // Any context that is created will be linked to the encapsulating transaction var repo = RepositoryFactory.CreateAuthorRepository(); var author = ObjectMother.Instance.Authors.CliveCustler; // Ensure author exists Assert.IsNotNull(repo.GetAuthorById(author.Id)); repo.RemoveAuthor(author.Id); // Ensure author is gone Assert.IsNull(repo.GetAuthorById(author.Id)); }
[TestMethod, Ignore] // Only VS Premium and Ultimate has Fakes public void TestShimCustomPropertyDelegate() { int response; const int expected = 70; using (ShimsContext.Create()) { ShimAuthor.AllInstances.AgeGet = _ => expected; var repo = RepositoryFactory.CreateAuthorRepository(); response = repo.GetAuthorById(ObjectMother.Instance.Authors.CliveCustler.Id).Age; } Assert.AreEqual(expected, response); }
[TestMethod, Ignore] // Only VS Premium and Ultimate has Fakes public void TestShimPropertyDelegateForDateTimeNow() { int response; const int expected = 77; using (ShimsContext.Create()) { // Generate fake DLL by right clicking on DLL reference 'System' (Unit Test Project) with interface and selecting 'Add Fakes Assembly' ShimDateTime.NowGet = () => new DateTime(2009, 1, 1); var repo = RepositoryFactory.CreateAuthorRepository(); response = repo.GetAuthorById(ObjectMother.Instance.Authors.CliveCustler.Id).Age; } Assert.AreEqual(expected, response); }
/// <summary> /// Constructor launches when class is initiated /// </summary> /// <param name="rFactory">Connection to Book Copy repository, creates its own through Factory pattern</param> public AuthorService(RepositoryFactory rFactory) { this.authorRepository = rFactory.CreateAuthorRepository(); }
/// <param name="rFactory">A repository factory, so the service can create its own repository.</param> public BookService(RepositoryFactory rFactory) { this.bookRepository = rFactory.CreateBookRepository(); this.authorRepository = rFactory.CreateAuthorRepository(); this.bookCopyRepository = rFactory.CreateBookCopyRepository(); }