コード例 #1
0
 public void GetAnnouncementById_Test_Is_Invoke_repository_GetById()
 {
     //Arrange
     var logger = new Mock<ILogger>();
     var iRepository = new Mock<IRepository<Announcement>>();
     var iUnitOfWork = new Mock<IUnitOfWork>();
     iUnitOfWork.Setup(st => st.AnnouncementRepository).Returns(iRepository.Object);
     var announcementService = new AnnouncementService(logger.Object, iUnitOfWork.Object);
     int anyIdMoreZero = 2;
     //Act
     announcementService.GetAnnouncementById(anyIdMoreZero);
     //Assert
     iRepository.Verify(inv => inv.GetById(anyIdMoreZero), Times.Once);
 }
コード例 #2
0
 public void GetAllAnnouncements_Test_If_Get_All_Announcement_Invoke_repository_GetAll()
 {
     //Arange
     var logger = new Mock<ILogger>();
     var iUnitOfWork = new Mock<IUnitOfWork>();
     var iRepository = new Mock<IRepository<Announcement>>();
     iUnitOfWork.Setup(st => st.AnnouncementRepository).Returns(iRepository.Object);
     var announcementService = new AnnouncementService(logger.Object, iUnitOfWork.Object);
     //Act
     announcementService.GetAllAnnouncements();
     //Assert
     iRepository.Verify(inv => inv.GetAll(), Times.Once);
 }