Skip to content

Latest commit

 

History

History

workshop

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Workshop

Today you will be TDD'ing a shopping cart.

Getting started

  1. Clone this repository: git clone git@github.com:dburriss/TestingWorkshop.git
  2. In this directory (the workshop directory) you will find starter projects for C# ,F#, and JS. Pick which is your preferred language and open it in your favorite editor.

Instructions

  1. Implement each feature before you move onto the next one (do not read ahead)
  2. You can ask colleagues or the instructor for help at any time
  3. You must have a failing test for any new code you write
  4. Try implement each feature in the most simple way possible
  5. Do not forget to go back and refactor once a test is passing

Assignment

Your team has been tasked with creating a new shopping cart experience. As this is a critical section of the website, as a team you have decided to TDD it as you have heard it lowers the occurrences of defects.

Basic definition of a product model:

data Product = {
    Id:unique identifier
    Code:6 letter alphanumeric
    Description:text
    Amount:number with decimal
    Version:integer
}

Part 1

Warming up. Implementing the basic cart functionality.

  1. As a customer I want to be able to add a product to my shopping cart so that I can carry on shopping and pay for it later
  2. As a customer I want to be able to remove a product from my shopping cart so that I can change my mind on what I want
  3. As a customer I want to be able to be able to increment the quantity of any item in my cart
  4. As a customer I want to be able to be able to decrement the quantity of any item in my cart
  5. As a customer I want to be able to be able to set the quantity of any item in my cart
  6. As a customer I want to be able to be able to see the total value of the current items in my cart

Part 2

Dealing with dependencies. We want visibility on what is happening on the cart. We want any changes to the contents of the cart to be logged. Ise ILogger in your cart implementation to send a log when products are added and removed. We also want to be able to see when exceptions occur.

  1. As a business analyst I want to be able to scrape the log files to the see what products were added and removed from carts so that I can analyze user behavior.
  2. As a developer I want to know what exceptions are happening in my cart so I can implement fixes for defects that block checkout.

Part 3

Dealing with change. There is an external API that allows you as a developer to POST a list of products to with quantities. You will get back the discounts that apply to the Product Lines as well as those applying to the cart as a whole.

Definition of Discounts model

data ItemDiscount = (PercentagePerProduct is percentage) OR (PercentagePerProductLine is percentage)

data ItemDiscountResult = {
    ProductId:unique identifier
    Discount: ItemDiscount
}

data CartDiscountResult is percentage

data Discount = ItemDiscountResult OR CartDiscountResult

data DiscountResult is list of Discount
  1. As a customer I want any discounts that apply to items in my cart to reflect in the item price and total price
  2. As a customer I want to see the amount of the discount on a Product Line so I know how much I am saving per line
  3. As a customer I want to see the amount of the discount due to the total contents of my cart so I know how much I am saving in total