Example #1
0
        public void Should_RepoGetAllExerciseTypes_ReturnEmptyList_WhenGetAllExerciseTypesCalledOnEmptyRepo()
        {
            List <ExerciseType> exerciseTypes = new List <ExerciseType>();

            var exerciseTypesQuery = exerciseTypes.AsQueryable();

            var mapper           = new Mock <IMapper>();
            var exerciseTypeRepo = new Mock <IExerciseTypeRepository>();

            exerciseTypeRepo.Setup(r => r.GetAllExerciseTypes()).Returns(exerciseTypesQuery);

            var expectedResult = new ListForExerciseTypeListVm()
            {
                ListForExerciseTypeList = new List <ExerciseTypeForListVm>(),
                PageSize     = 1,
                CurrentPage  = 1,
                SearchString = string.Empty,
                Count        = 0
            };

            var objectUnderTest = new ExerciseTypeService(exerciseTypeRepo.Object, mapper.Object);

            var result = objectUnderTest.GetAllExerciseTypes(1, 1, string.Empty);

            bool areListsEqual = AreListsForExerciseTypesEqual(result, expectedResult);

            Assert.True(areListsEqual);
        }
Example #2
0
        public void Should_RepoGetAllExerciseTypes_BeCalled_WhenGetAllExerciseTypesCalled()
        {
            var mapper           = new Mock <IMapper>();
            var exerciseTypeRepo = new Mock <IExerciseTypeRepository>();
            var objectUnderTest  = new ExerciseTypeService(exerciseTypeRepo.Object, mapper.Object);

            exerciseTypeRepo.Setup(r => r.GetAllExerciseTypes()).Returns(new List <ExerciseType>().AsQueryable());

            objectUnderTest.GetAllExerciseTypes(1, 1, string.Empty);

            exerciseTypeRepo.Verify(r => r.GetAllExerciseTypes(), Times.Once);
        }
Example #3
0
        public void Should_RepoGetAllExerciseTypes_ReturnOnlyFirstVm_WhenGetAllExerciseTypesCalledWithPageSizeOne()
        {
            List <Exercise> exercises = new List <Exercise>()
            {
                new Exercise()
                {
                    Id = 1, Name = "dummyExercise1", ExerciseTypeId = 1
                },
                new Exercise()
                {
                    Id = 2, Name = "dummyExercise2", ExerciseTypeId = 1
                }
            };

            List <ExerciseType> exerciseTypes = new List <ExerciseType>()
            {
                new ExerciseType()
                {
                    Id        = 1,
                    Name      = "dummy 1",
                    Exercises = exercises
                },
                new ExerciseType()
                {
                    Id        = 2,
                    Name      = "dummy 2",
                    Exercises = exercises
                },
                new ExerciseType()
                {
                    Id        = 3,
                    Name      = "dummy 3",
                    Exercises = exercises
                }
            };

            var exerciseTypesQuery = exerciseTypes.AsQueryable();

            var exerciseTypeRepo = new Mock <IExerciseTypeRepository>();
            var mapper           = new Mock <IMapper>();

            exerciseTypeRepo.Setup(r => r.GetAllExerciseTypes()).Returns(exerciseTypesQuery);

            var expectedResult = new ListForExerciseTypeListVm()
            {
                ListForExerciseTypeList = new List <ExerciseTypeForListVm>()
                {
                    new ExerciseTypeForListVm()
                    {
                        Id   = 1,
                        Name = "dummy 1",
                    },
                },
                PageSize     = 1,
                CurrentPage  = 1,
                SearchString = string.Empty,
                Count        = 3
            };

            var objectUnderTest = new ExerciseTypeService(exerciseTypeRepo.Object, mapper.Object);

            var result = objectUnderTest.GetAllExerciseTypes(1, 1, string.Empty);

            bool areListsEqual = AreListsForExerciseTypesEqual(result, expectedResult);

            Assert.True(areListsEqual);
        }