public void GetChildPagesShould_ReturnCorrectValue() { // Arrange int bookCatNum = 1; Guid bookId = Guid.NewGuid(); Book book = new Book() { Id = bookId, CatalogueNumber = bookCatNum }; int parentPageNum1 = 1; int parentPageNum2 = 2; PageConnection pageConnection1 = new PageConnection() { Book = book, ParentPageNumber = parentPageNum1 }; PageConnection pageConnection2 = new PageConnection() { Book = book, ParentPageNumber = parentPageNum2 }; var listBoth = new List <PageConnection>() { pageConnection1, pageConnection2 }; var pageConnectionsService = new PageConnectionsService(pageConnectionsRepoMock.Object, bookServiceMock.Object, contextMock.Object); // Act pageConnectionsRepoMock.Setup(x => x.All).Returns(listBoth.AsQueryable); bookServiceMock.Setup(x => x.FindSingle(bookCatNum)).Returns(book); var result = pageConnectionsService.GetChildPages(bookCatNum, parentPageNum2); // Assert Assert.AreEqual(pageConnection2, result.First()); }
private void SeedSamplePages(MsSqlDbContext context) { if (!context.Pages.Any()) { for (int i = 1; i < 51; i++) { var page = new Page() { Book = context.Books.First(x => x.CatalogueNumber == 1), Number = i, Text = "Page " + i + " Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", Author = context.Users.First(x => x.Email == AdministratorUserName), CreatedOn = DateTime.Now }; context.Pages.Add(page); var pageConnection = new PageConnection() { Book = context.Books.First(x => x.CatalogueNumber == 1), ParentPageNumber = 1, Text = "Go to ", ChildPageNumber = i, Author = context.Users.First(x => x.Email == AdministratorUserName), CreatedOn = DateTime.Now }; context.PageConnections.Add(pageConnection); } } }
public xinlongyuReviewControl() { InitializeComponent(); // _pageConnection = new PageConnection(); txtPageId.TipText = "请输入页面ID"; // RefreshTreeView(); }
public void UpdateShould_ReturnValue() { // Arrange var pageConnectionsService = new PageConnectionsService(pageConnectionsRepoMock.Object, bookServiceMock.Object, contextMock.Object); PageConnection pageConnection = new PageConnection(); // Arrange contextMock.Setup(x => x.Commit()).Returns(1); var result = pageConnectionsService.Update(pageConnection); // Assert Assert.IsInstanceOf(typeof(int), result); }
public int Update(PageConnection pageConnection) { this.pageConnectionsRepo.Update(pageConnection); return(this.context.Commit()); }
public int Add(PageConnection pageConnection) { this.pageConnectionsRepo.Add(pageConnection); return(this.context.Commit()); }