Ejemplo n.º 1
0
        public void GetAllNames_ShouldReturnICollectionOfTwoStringsWhenTwoExercisesArePresentInTheRepo()
        {
            var workoutInformationRepoStub = new Mock <IEfRepostory <WorkoutInformation> >();
            var unitOfWorkStub             = new Mock <IUnitOfWork>();

            var list       = new List <WorkoutInformation>();
            var workoutOne = new WorkoutInformation();

            workoutOne.Name = "gosho";
            var workoutTwo = new WorkoutInformation
            {
                Name = "pesho"
            };

            list.Add(workoutOne);
            list.Add(workoutTwo);

            var dbSetStub = list.AsQueryable();

            var sut = new WorkoutInformationService(workoutInformationRepoStub.Object, unitOfWorkStub.Object);

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

            var result = sut.GetAllNames();

            Assert.AreEqual(2, result.Count);
        }
Ejemplo n.º 2
0
        public void GetAllNames_ShouldCallWorkoutInformationRepoAllPropertyOnce()
        {
            var workoutInformationRepoStub = new Mock <IEfRepostory <WorkoutInformation> >();
            var unitOfWorkStub             = new Mock <IUnitOfWork>();
            var dbSetStub = new List <WorkoutInformation>().AsQueryable();

            var sut = new WorkoutInformationService(workoutInformationRepoStub.Object, unitOfWorkStub.Object);

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

            var result = sut.GetAllNames();

            workoutInformationRepoStub.Verify(x => x.All, Times.Once);
        }
Ejemplo n.º 3
0
        public void GetAllNames_ShouldReturnICollectionOfStrings()
        {
            var workoutInformationRepoStub = new Mock <IEfRepostory <WorkoutInformation> >();
            var unitOfWorkStub             = new Mock <IUnitOfWork>();

            var list    = new List <WorkoutInformation>();
            var workout = new WorkoutInformation();

            workout.Name = "murph";
            list.Add(workout);

            var dbSetStub = list.AsQueryable();

            var sut = new WorkoutInformationService(workoutInformationRepoStub.Object, unitOfWorkStub.Object);

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

            var result = sut.GetAllNames();

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