Beispiel #1
0
 private void GivenWaiterInformation(Waiter newGuy)
 {
     Assert.False(string.IsNullOrEmpty(newGuy.FirstName));
     Assert.False(string.IsNullOrEmpty(newGuy.LastName));
     Assert.False(string.IsNullOrEmpty(newGuy.Address));
     Assert.False(string.IsNullOrEmpty(newGuy.Phone));
 }
Beispiel #2
0
        private void WhenIAddTheWaiter(Waiter newGuy, out int waiterId)
        {
            //sut ==> "system under test"
            var sut = new RestaurantAdminController();
            waiterId = sut.AddWaiter(newGuy);

        }
 public void DeleteWaiter(Waiter item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         var existing = context.Waiters.Find(item.WaiterID);
         context.Waiters.Remove(existing);
         context.SaveChanges();
     }
 }
 public int AddWaiter(Waiter item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         // TODO: Validation rules...
         var added = context.Waiters.Add(item);
         context.SaveChanges();
         return added.WaiterID;
     }
 }
 public void DeleteWaiter(Waiter item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         //TODO: Validation of waiter data...
         var existing = context.Waiters.Find(item.WaiterID);
         context.Waiters.Remove(existing);
         context.SaveChanges();
     }
 }
 public void UpdateWaiter(Waiter item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         // TODO: Validation...
         var attached = context.Waiters.Attach(item);
         var existing = context.Entry<Waiter>(attached);
         existing.State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
 public void UpdateWaiter(Waiter item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         //todo: Validation
         var attached = context.Waiters.Attach(item);
         var matchingWithExistingValues = context.Entry<Waiter>(attached);
         matchingWithExistingValues.State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Beispiel #8
0
 public void AddWaiterScenario()
 {
     Waiter newGuy = new Waiter()
     {
         FirstName = "Fred",
         LastName = "Flintstone",
         Address = "123 Bedrock",
         Phone = "780.555.1212"
     };
     int waiterId = -1;
     this.Given(_ => GivenWaiterInformation(newGuy))
         .When(_ => WhenIAddTheWaiter(newGuy, out waiterId))
         .Then(_ => ThenTheWaiterExists(waiterId))
         .And(_ => ThenAttributeWaiterDetailsMatch(waiterId, newGuy))
         .BDDfy();
 }
        public void AddWaiterScenario()
        {
            Waiter newGuy = new Waiter()
            {
                FirstName = "Fred",
                LastName = "Flintstone",
                Address = "123 Bedrock",
                Phone = "780.555.1212",
                HireDate = DateTime.Today.AddDays(-3)
            };


            int WaiterID = -1;
            this.Given(_ => GivenWaiterInformation(newGuy))
                .When(_ => WhenIAddTheWaiter(newGuy, out WaiterID))
                .Then(_ => ThenTheWaiterExists(WaiterID))
                .And(_ => TheWaiterDetailsMatch(WaiterID, newGuy))
                .BDDfy();
        }
Beispiel #10
0
 private void TheWaiterDetailsMatch(int waiterId, Waiter newGuy)
 {
     var sut = new RestaurantAdminController();
     // TODO: Compare the actual waiter info with the expected
 }
        private void WhenIAddTheWaiter(Waiter newGuy, out int WaiterID)
        {
            var sut = new RestaurantAdminController();
            WaiterID = sut.AddWaiter(newGuy);

        }