public void GetAllAdmin_ShouldReturnAllDrivesAsAdminDriveIndexViewModel() { // arrange Mock <IDbRepository <Drive> > mockRepository = new Mock <IDbRepository <Drive> >(); mockRepository.Setup(m => m.GetAll()) .Returns(new List <Drive>() { new Drive() { Id = 1 }, new Drive() { Id = 2 } }.AsQueryable()); IMapper mapper = new Mapper(new MapperConfiguration(cfg => cfg.CreateMap <Drive, DriveAdminIndexViewModel>() .ForMember(dest => dest.From, opt => opt.MapFrom(source => source.From.Name)) .ForMember(dest => dest.To, opt => opt.MapFrom(source => source.To.Name)) .ForMember(dest => dest.Date, opt => opt.MapFrom(source => source.DateTime.ToString("dd/MM/yyyy HH:mm"))))); IDrivesService service = new DrivesService(mockRepository.Object, mapper, null); // act var result = service.GetAllAdmin().Count(); // assert result.Should().Be(2); }