public void ValidatesIncompleteBicycle()
 {
     Bicycle bicycle = null;
     ValidationResult validationResult = null;
     "Given an empty bicycle instance"
         .Given(() =>
         {
             bicycle = new Bicycle();
         });
     "When is validated"
         .When(() =>
         {
             IBicyleRepository bicyleRepository = Mock.Of<IBicyleRepository>();
             var bicycleValidator = new BicycleValidator(bicyleRepository);
             validationResult = bicycleValidator.Validate(bicycle);
         });
     "Then the bicycle is not valid"
         .Then(() =>
         {
             Assert.False(validationResult.IsValid);
         });
     "And it has three validation errors"
         .Then(() =>
         {
             Assert.Equal(3, validationResult.Errors.Count);
         });
 }
 public Bicycle Put(Bicycle request)
 {
     Bicycle bicycle = BicyleRepository.Single(b => b.Id == request.Id);
     bicycle.Name = request.Name;
     bicycle.Type = request.Type;
     bicycle.Quantity = request.Quantity;
     bicycle.RentPrice = request.RentPrice;
     return bicycle;
 }
        public void TypeNameIsFormatted()
        {
            var bicycle = new Bicycle
            {
                Type = BicycleTypes.MountainBike
            };

            Assert.Equal("Mountain Bike", bicycle.TypeName);
        }
 public Bicycle Update(Bicycle sourceBicycle)
 {
     Bicycle bicycle = Single(b => b.Id == sourceBicycle.Id);
     bicycle.Name = sourceBicycle.Name;
     bicycle.Type = sourceBicycle.Type;
     bicycle.Quantity = sourceBicycle.Quantity;
     bicycle.RentPrice = sourceBicycle.RentPrice;
     Db.Update(bicycle);
     return bicycle;
 }
 public void Add(Bicycle bicycle)
 {
     Db.Insert(bicycle);
     bicycle.Id = (int)Db.GetLastInsertId();
 }
 public Bicycle Post(Bicycle request)
 {
     BicyleRepository.Add(request);
     return request;
 }
 public void Add(Bicycle bicycle)
 {
     bicycle.Id = _bicycles.Count + 1;
     _bicycles.Add(bicycle);
 }
 public Bicycle Put(Bicycle request)
 {
     return BicyleRepository.Update(request);
 }
Example #9
0
 public void Add(Bicycle bicycle)
 {
     Db.Insert(bicycle);
     bicycle.Id = (int)Db.GetLastInsertId();
 }