Пример #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));
 }
Пример #2
0
        private void WhenIAddTheWaiter(Waiter newGuy, out int waiterId)
        {
            //sut ==> "system under test"
            var sut = new RestaurantAdminController();
            waiterId = sut.AddWaiter(newGuy);

        }
Пример #3
0
 public void DeleteWaiter(Waiter item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         var existing = context.Waiters.Find(item.WaiterID);
         context.Waiters.Remove(existing);
         context.SaveChanges();
     }
 }
Пример #4
0
 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();
     }
 }
Пример #6
0
 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();
     }
 }
Пример #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();
 }
Пример #9
0
        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();
        }
Пример #10
0
 private void TheWaiterDetailsMatch(int waiterId, Waiter newGuy)
 {
     var sut = new RestaurantAdminController();
     // TODO: Compare the actual waiter info with the expected
 }
Пример #11
0
        private void WhenIAddTheWaiter(Waiter newGuy, out int WaiterID)
        {
            var sut = new RestaurantAdminController();
            WaiterID = sut.AddWaiter(newGuy);

        }