Refactor complete, all tests still pass

This commit is contained in:
Simon Brooke 2019-05-18 10:17:15 +01:00
parent 23e24bd381
commit 66388bc944
20 changed files with 509 additions and 486 deletions

View file

@ -0,0 +1,24 @@
(ns the-great-game.merchants.merchant-utils-test
(:require [clojure.test :refer :all]
[the-great-game.utils :refer [deep-merge]]
[the-great-game.world.world :refer [default-world]]
[the-great-game.merchants.merchant-utils :refer :all]))
(deftest expected-price-test
(testing "Anticipated prices in markets"
(let [world (deep-merge
default-world
{:merchants
{:archie
{:known-prices
{:buckie
{:iron
[{:price 1.7 :date 1}
{:price 2 :date 0}]}}}}})]
(let [actual (expected-price (-> world :merchants :archie) :fish :edinburgh)
expected 1] ;;
(is (= actual expected) "if no information assume 1"))
(let [actual (expected-price (-> world :merchants :archie) :iron :buckie)
expected 1.7] ;;
(is (= actual expected) "if information select the most recent")))))

View file

@ -1,26 +1,9 @@
(ns the-great-game.merchants.merchants-test
(ns the-great-game.merchants.planning-test
(:require [clojure.test :refer :all]
[the-great-game.utils :refer [deep-merge]]
[the-great-game.world.world :refer [default-world]]
[the-great-game.merchants.merchants :refer :all]))
[the-great-game.merchants.planning :refer :all]))
(deftest expected-price-test
(testing "Anticipated prices in markets"
(let [world (deep-merge
default-world
{:merchants
{:archie
{:known-prices
{:buckie
{:iron
[{:price 1.7 :date 1}
{:price 2 :date 0}]}}}}})]
(let [actual (expected-price (-> world :merchants :archie) :fish :edinburgh)
expected 1] ;;
(is (= actual expected) "if no information assume 1"))
(let [actual (expected-price (-> world :merchants :archie) :iron :buckie)
expected 1.7] ;;
(is (= actual expected) "if information select the most recent")))))
(deftest plan-trade-test
(testing "Lower level trade planning"