public void AddsExerciseToCurrentWorkout()
        {
            var wk = new Workout();
            var service = NSubstitute.Substitute.For<IWorkoutService>();
            service.CurrentWorkout().Returns(wk);
            var command = new AddStrengthCommand(new AddStrengthInputModel {Description = "a", Repetitions = 1, Weight = 10});
            AutoMapper.Mapper.Initialize(x => x.AddProfile<Core.Mapping.StrengthMappingProfile>());

            var handler = new AddStrengthCommandHandler(service);
            handler.Handle(command);

            wk.Strength.Count.ShouldEqual(1);
        }
        public void AddsExerciseToCurrentWorkout()
        {
            var wk = new Workout();
            var service = NSubstitute.Substitute.For<IWorkoutService>();
            service.CurrentWorkout().Returns(x => wk);
            var dataSource = new EllipticalViewModel {Calories = 800, Duration = 45, Level = 6, Program = "M"};
            var command = new AddCardioCommand(dataSource);
            AutoMapper.Mapper.Initialize(x => x.AddProfile<Core.Mapping.CardioMappingProfile>());

            var handler = new AddCardioCommandHandler(service);
            handler.Handle(command);

            wk.Cardio.Count.ShouldEqual(1);
        }
示例#3
0
        public void OMGDataGoesInTheCloud()
        {
            var documentStore = new DocumentStore
            {
                Url = "https://ec2-eu3.cloudbird.net/databases/c9558cb7-01d2-42a9-923d-ce1d05b1543a.Raven2",
                ApiKey = "bc97ecdc-64e5-49de-a9f2-9dab608bdee2"
            };
            documentStore.Initialize();

            var session = documentStore.OpenSession();

            IRepository<Workout> repo = new Repository<Workout>(session);
            var wk = new Workout();
            repo.Add(wk);

            session.SaveChanges();
        }
示例#4
0
            public void TheExcerciseIsAddedToTheCurrentWorkout()
            {
                var wk = new Workout();
                var id = Guid.NewGuid();
                var repo = Substitute.For<IRepository<Workout>>();
                var session = Substitute.For<ISessionStorage>();

                session.UserData.Returns(CreateFakeIdentity());
                repo.Single(Arg.Any<OpenWorkoutForUserQuery>()).Returns(wk);

                var service = new WorkoutService(repo, session, null);

                //Act
                var cardio = new EllipticalViewModel();
                service.AddCardio(cardio);

                //Assert
                wk.Cardio.Count.ShouldEqual(1);
            }
示例#5
0
 public void CanAddACardioSegmentToAWorkout()
 {
     var wk = new Workout();
     wk.AddCardio(new CardioSegment());
     wk.Cardio.Count.ShouldEqual(1);
 }
示例#6
0
 public void AWorkoutThatEndsWillHaveAnEndDate()
 {
     var wk = new Workout();
     wk.End();
     wk.EndDate.HasValue.ShouldBeTrue();
 }
示例#7
0
 public void AWorkoutIsInitializedWithAStartDate()
 {
     var wk = new Workout();
     wk.StartDate.HasValue.ShouldBeTrue();
 }
示例#8
0
                public void IfWorkoutExistsInRepoItIsReturned()
                {
                    //Arrange
                    var identity = CreateFakeIdentity();
                    identity.UserInfo.Id = Guid.NewGuid();
                    var existing = new Workout { Id = Guid.NewGuid() };
                    _storage.UserData.Returns(identity);
                    _repository.Single(Arg.Any<OpenWorkoutForUserQuery>()).Returns(existing);

                    //Act
                    var wk = _service.CurrentWorkout();

                    //Assert
                    _repository.Received(1).Single(Arg.Is<OpenWorkoutForUserQuery>(q => q.UserId == identity.UserInfo.Id));
                    wk.ShouldBeSameAs(existing);
                }