Пример #1
0
      [TestCase(100)]    // Should fail
      public void GivenAnInvoiceCalculator_WithInvalidAmount_CalculateShouldThrowException(decimal subtotal)
      {
          // Arrange:
          var someInvoiceCalculator = new InvoiceTotal.InvoiceCalculator();

          // Act & Assert:
          Assert.Throws <ArgumentException>(() => someInvoiceCalculator.Calculate(subtotal));
      }
Пример #2
0
      [TestCase(100, 25, 75)]   // Should pass
      public void GivenAnInvoiceCalculator_Calculate_CalculatesCorrectly(decimal subtotal,
                                                                         decimal expDiscountedAmount, decimal expInvoiceTotal)
      {
          // Arrange:
          var someInvoiceCalculator = new InvoiceTotal.InvoiceCalculator();

          // Act:
          someInvoiceCalculator.Calculate(subtotal);

          // Assert:
          Assert.AreEqual(someInvoiceCalculator.discountedAmount, expDiscountedAmount, $"The expected discounted amount did not match: {someInvoiceCalculator.discountedAmount}.");
          Assert.AreEqual(someInvoiceCalculator.invoiceTotal, expInvoiceTotal, $"The expected invoice amount did not match: {someInvoiceCalculator.invoiceTotal}.");
      }
Пример #3
0
      public void GivenAnInvoiceCalculator_Reset_SetsAllValuesToZero()
      {
          //Arrange:
          var someInvoiceCalculator = new InvoiceTotal.InvoiceCalculator();

          someInvoiceCalculator.discountedAmount = 200;
          someInvoiceCalculator.invoiceTotal     = 3;

          //Act:
          someInvoiceCalculator.Reset();

          // Assert:
          Assert.AreEqual(someInvoiceCalculator.discountedAmount, 0);
          Assert.AreEqual(someInvoiceCalculator.invoiceTotal, 0);
      }