private List<Exercise> GetExercises()
        {
            var exerciseService = new ExerciseService(new ExerciseRepository(), new MuscleRepository());
            List<Exercise> allExercises = exerciseService.GetAll();

            return allExercises;
        }
        private void MethodGetAllReturnsListOfExercise()
        {
            _repository.Setup(repo => repo.GetAll()).Returns(_exercises);

            var actionResult = _service.GetAll();

            Assert.Equal(_exerciseDtos, actionResult);
        }
Example #3
0
        public void GetAll()
        {
            //Arrange
            _mock.Setup(s => s.GetAll()).Returns(_exercises);

            //Act
            var result = _exerciseService.GetAll();

            //Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count() > 0);
            Assert.IsInstanceOfType(result, typeof(IEnumerable <ExerciseDTO>));
        }
Example #4
0
        public void GetAll_ShouldReturnAnICollectionOfExercises()
        {
            var exercisesRepoStub = new Mock <IEfRepostory <Exercise> >();
            var unitOfWorkStub    = new Mock <IUnitOfWork>();
            var dbSetStub         = new Mock <IList <Exercise> >().As <IQueryable <Exercise> >();

            var sut = new ExerciseService(exercisesRepoStub.Object, unitOfWorkStub.Object);

            exercisesRepoStub.Setup(x => x.All).Returns(dbSetStub.Object);

            var result = sut.GetAll();

            Assert.IsInstanceOf(typeof(ICollection <Exercise>), result);
        }
Example #5
0
        public void GetAll_ShouldCallExerciseRepoAllPropertyOnce()
        {
            var exercisesRepoStub = new Mock <IEfRepostory <Exercise> >();
            var unitOfWorkStub    = new Mock <IUnitOfWork>();
            var dbSetStub         = new List <Exercise>().AsQueryable();

            var sut = new ExerciseService(exercisesRepoStub.Object, unitOfWorkStub.Object);

            exercisesRepoStub.Setup(x => x.All).Returns(dbSetStub);

            var result = sut.GetAll();

            exercisesRepoStub.Verify(x => x.All, Times.Once);
        }
Example #6
0
        public void GetAll_NotNull()
        {
            IEnumerable <Exercise> exercises = service.GetAll();

            Assert.That(exercises, Is.Not.Null);
        }