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);
         });
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
        public void TypeNameIsFormatted()
        {
            var bicycle = new Bicycle
            {
                Type = BicycleTypes.MountainBike
            };

            Assert.Equal("Mountain Bike", bicycle.TypeName);
        }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
 public void Add(Bicycle bicycle)
 {
     Db.Insert(bicycle);
     bicycle.Id = (int)Db.GetLastInsertId();
 }
Ejemplo n.º 6
0
 public Bicycle Post(Bicycle request)
 {
     BicyleRepository.Add(request);
     return request;
 }
Ejemplo n.º 7
0
 public void Add(Bicycle bicycle)
 {
     bicycle.Id = _bicycles.Count + 1;
     _bicycles.Add(bicycle);
 }
Ejemplo n.º 8
0
 public Bicycle Put(Bicycle request)
 {
     return BicyleRepository.Update(request);
 }
Ejemplo n.º 9
0
 public void Add(Bicycle bicycle)
 {
     Db.Insert(bicycle);
     bicycle.Id = (int)Db.GetLastInsertId();
 }