示例#1
0
        public async Task GetAll_Sucess()
        {
            var mock = new Mock <IWorkblockService>();
            WorkblocksController controller = new WorkblocksController(mock.Object);

            var result = await controller.GetAll();

            mock.Verify(service => service.GetAllAsync(), Times.AtLeastOnce());
        }
示例#2
0
        public async Task GetAll_Sucess()
        {
            var mockRepository = new Mock <IWorkblockRepository>();

            mockRepository.Setup(repository => repository.GetAllAsync()).Returns(Task.FromResult(new List <Workblock>()));

            var mockUnit = new Mock <IUnitOfWork>();

            WorkblockService     WorkblockService = new WorkblockService(mockUnit.Object, mockRepository.Object);
            WorkblocksController controller       = new WorkblocksController(WorkblockService);

            var result = await controller.GetAll();

            mockRepository.Verify(repository => repository.GetAllAsync(), Times.AtLeastOnce());
            Assert.IsInstanceOfType(result, typeof(ActionResult <IEnumerable <WorkblockDto> >));
        }