public void ShouldReturnAllSchedules()
        {
            var sourceCollectionMock  = new Mock <IQueryable <Schedule> >();
            var destinationCollection = new Mock <IQueryable <ScheduleViewModel> >();

            mapperMock.Setup(x => x.ProjectTo <ScheduleViewModel>(sourceCollectionMock.Object, null))
            .Returns(destinationCollection.Object);
            serviceMock.Setup(x => x.GetAll()).Returns(sourceCollectionMock.Object);

            var result = controller.GetAll();

            Assert.AreEqual(destinationCollection.Object, result);
            mapperMock.Verify(x => x.ProjectTo <ScheduleViewModel>(sourceCollectionMock.Object, null),
                              Times.Once());
            serviceMock.Verify(x => x.GetAll(), Times.Once());
        }
Пример #2
0
        public void GetAllSchedules_UnderNormalConditions_ReturnsListOfSchedules()
        {
            //Arrange
            Mock.Arrange(() => _mockScheduleService.GetAll()).Returns(_scheduleList).OccursOnce();
            var expected = _scheduleList;

            var scheduleController = new ScheduleController(_mockScheduleService);

            //Act
            var actual        = scheduleController.GetAll() as OkNegotiatedContentResult <List <ScheduleDto> >;
            var actualContent = actual.Content;


            //Assert
            Mock.Assert(_mockScheduleService);
            Assert.That(actualContent, Is.EqualTo(expected));
        }