예제 #1
0
        public void Beer_DrinkTwoTimes_BillIsTwoPrice()
        {
            // Arrange
            decimal price = 1.5M;
            var     sut   = new Beer(price);

            // Act
            sut.Drink();
            sut.Drink();
            // Assert
            Assert.AreEqual(price * 2, sut.Bill);
        }
예제 #2
0
    public void BeerDrink_WhenDrink_DrankWhenNotNull()
    {
        var beer = new Beer();

        beer.Drink();
        beer.DrankWhen.ShouldNotBeNull();
    }
예제 #3
0
        public void Beer_DrinkOne_BillIsOneTimePrice()
        {
            decimal price = 1.5M;
            var     sut   = new Beer(price);

            sut.Drink();
            Assert.AreEqual(price, sut.Bill);
        }
예제 #4
0
    public void BeerDrink_WhenDrink_DrankTrue()
    {
        var beer = new Beer();

        beer.Drink();

        (beer.Drank != null && beer.Drank.Value).ShouldBeTrue();
    }
예제 #5
0
    public void BeerDrink_WhenDrink_LocationNull()
    {
        var beer = new Beer {
            Location = "test"
        };

        beer.Drink();

        beer.Location.ShouldBeNull();
    }
예제 #6
0
 public void GetBuzzed(int OneHundredBottlesOfBeerOnTheWall)
 {
     for (int beer = 1; beer <= OneHundredBottlesOfBeerOnTheWall; beer++)
     {
         if (beer % 3 == 0 && beer % 5 == 0)
         {
             Beer.Drink(this.Derp);
         }
         else if (beer % 3 == 0)
         {
             Beer.Drink(this.Burp);
         }
         else if (beer % 5 == 0)
         {
             Beer.Drink(this.SuperBurp);
         }
         else
         {
             Beer.Drink(beer.ToString());
         }
     }
 }
예제 #7
0
        public void TestLoggingOnMethod()
        {
            var b = new Beer();

            //reset logger
            Logger.Reset();
            //make sure the logger is at count == 0
            Assert.AreEqual(Logger.Log.Count, 0);

            //drink beer :)
            b.Drink();

            //make sure the beer is alright
            Assert.IsTrue(b.Empty);
            Assert.IsFalse(b.Full);
            Assert.IsFalse(b.Dropped);

            //The number of log messages must be ok
            Assert.AreEqual(Logger.Log.Count, 2);
            //the log must contain correct info
            Assert.AreEqual("Before LoggingAmender.Logger.Drink()", Logger.Log[0]);
            Assert.AreEqual("After LoggingAmender.Logger.Drink()", Logger.Log[1]);
        }
        protected void btnOpenAndDrink_Click(object sender, EventArgs e)
        {
            // Creating beer
            Beer createdBeer = new Beer(this.txtName.Text
                                        , "Brasil"
                                        , Convert.ToDouble(this.txtInitialWeight.Text));

            // Opening beer
            createdBeer.Open();
            // Drinking the beer
            double w = Convert.ToDouble(this.txtWeight.Text);

            createdBeer.Drink(weight: w);

            // Consuming IEnumerable of errors
            //IEnumerable<string> errors = createdBeer.DrinkAndGetErrors(w);

            #region Displaying errors

            if (createdBeer.Errors.Count > 0)
            {
                StringBuilder errorBuilder = new StringBuilder();
                foreach (string error in createdBeer.Errors)
                {
                    errorBuilder.AppendLine(error);
                }
                this.lblErrors.Visible = true;
                this.lblErrors.Text    = errorBuilder.ToString();
            }
            else
            {
                this.lblResult.Visible = true;
                this.lblResult.Text    = "Drank with success! You can still drink more " + createdBeer.Weight + " ml";
            }

            #endregion
        }