public void GetById_ShouldCallPendingWorkoutsRepoAllPropertyOnce() { var pendingWorkoutsStub = new Mock <IEfRepostory <PendingWorkout> >(); var unitOfWorkStub = new Mock <IUnitOfWork>(); var dbSetStub = new List <PendingWorkout>().AsQueryable(); var id = new Guid(); var sut = new PendingWorkoutService(pendingWorkoutsStub.Object, unitOfWorkStub.Object); pendingWorkoutsStub.Setup(x => x.All).Returns(dbSetStub); var result = sut.GetById(id); pendingWorkoutsStub.Verify(x => x.All, Times.Once); }
public void GetById_ShouldReturnCorrectEntryWhenIdMatchesThePasedId() { var pendingWorkoutsStub = new Mock <IEfRepostory <PendingWorkout> >(); var unitOfWorkStub = new Mock <IUnitOfWork>(); var list = new List <PendingWorkout>(); var workout = new PendingWorkout(); list.Add(workout); var dbSetStub = list.AsQueryable(); var sut = new PendingWorkoutService(pendingWorkoutsStub.Object, unitOfWorkStub.Object); pendingWorkoutsStub.Setup(x => x.All).Returns(dbSetStub); var result = sut.GetById(workout.Id); Assert.IsNotNull(result); Assert.IsInstanceOf <PendingWorkout>(result); Assert.AreSame(result, workout); }
public void GetById_ShouldReturnNullWhenNoEntryMatchesTheId() { var pendingWorkoutsStub = new Mock <IEfRepostory <PendingWorkout> >(); var unitOfWorkStub = new Mock <IUnitOfWork>(); var list = new List <PendingWorkout>(); var workout = new PendingWorkout(); list.Add(workout); var dbSetStub = list.AsQueryable(); var sut = new PendingWorkoutService(pendingWorkoutsStub.Object, unitOfWorkStub.Object); pendingWorkoutsStub.Setup(x => x.All).Returns(dbSetStub); var newId = new Guid(); var result = sut.GetById(newId); Assert.IsNull(result); }