Esempio n. 1
0
        public void TheAddEllipticalMethod()
        {
            var commandInvoker = Substitute.For<ICommandInvoker>();
            var controller = new CardioController(null, commandInvoker);
            var inModel = new EllipticalViewModel {Calories = 7, Duration = 8, Level = 9, Program = "a"};

            controller.AddElliptical(inModel);
            commandInvoker.Received(1).Execute(Arg.Is<AddCardioCommand>(x => x.ToAdd.Equals(inModel)));
        }
        public void CardioSegmentsCanBeMappedBack()
        {
            MappingBootstrapper.Initialize();

            var ellSource = new EllipticalViewModel {Calories = 700, Duration = 45, Level = 6, Program = "M"};
            var segment = Mapper.Map<CardioSegment>(ellSource);

            var dest = Mapper.Map(segment, typeof (CardioSegment), ellSource.GetType());
            Assert.IsNotNull(dest);
        }
        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);
        }
Esempio n. 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);
            }
Esempio n. 5
0
 public ActionResult AddElliptical(EllipticalViewModel inModel)
 {
     return AddCardio(inModel);
 }