コード例 #1
0
        public void GetAllExerciseNames_ShouldReturnICollectionOfTwoStringsWhenTwoExercisesArePresentInTheRepo()
        {
            var exercisesRepoStub = new Mock <IEfRepostory <Exercise> >();
            var unitOfWorkStub    = new Mock <IUnitOfWork>();

            var list        = new List <Exercise>();
            var exerciseOne = new Exercise();

            exerciseOne.Name = "gosho";
            var exerciseTwo = new Exercise
            {
                Name = "pesho"
            };

            list.Add(exerciseOne);
            list.Add(exerciseTwo);

            var dbSetStub = list.AsQueryable();

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

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

            var result = sut.GetAllExerciseNames();

            Assert.AreEqual(2, result.Count);
        }
コード例 #2
0
        public void GetAllExerciseNames_ShouldExerciseRepoAllPropertyOnce()
        {
            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.GetAllExerciseNames();

            exercisesRepoStub.Verify(x => x.All, Times.Once);
        }
コード例 #3
0
        public void GetAllExerciseNames_ShouldICollectionOfStrings()
        {
            var exercisesRepoStub = new Mock <IEfRepostory <Exercise> >();
            var unitOfWorkStub    = new Mock <IUnitOfWork>();

            var list     = new List <Exercise>();
            var exercise = new Exercise();

            exercise.Name = "gosho";
            list.Add(exercise);

            var dbSetStub = list.AsQueryable();

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

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

            var result = sut.GetAllExerciseNames();

            Assert.IsInstanceOf(typeof(ICollection <string>), result);
        }