Exemple #1
0
        public void CanAddAPrice()
        {
            PriceAdded[] events =
            {
                new PriceAdded("A", 50)
            };

            var priceList = new PriceList();

            priceList.Apply(events);

            var price = priceList.PriceFor("A");

            Assert.Equal(50, price);
        }
Exemple #2
0
        public void CanGetPriceForMultipleSKU()
        {
            PriceAdded[] events =
            {
                new PriceAdded("A", 50),
                new PriceAdded("B", 30)
            };

            var priceList = new PriceList();

            priceList.Apply(events);

            Assert.Equal(50, priceList.PriceFor("A"));
            Assert.Equal(30, priceList.PriceFor("B"));
        }
Exemple #3
0
        public void CanGetOnlyTheLatestPrice()
        {
            PriceAdded[] events =
            {
                new PriceAdded("A", 50),
                new PriceAdded("A", 20)
            };

            var priceList = new PriceList();

            priceList.Apply(events);

            var price = priceList.PriceFor("A");

            Assert.Equal(20, price);
        }
Exemple #4
0
        public void ThrowsANiceExceptionWhenSKUIsUnknown()
        {
            PriceAdded[] events =
            {
                new PriceAdded("A", 50),
                new PriceAdded("B", 30)
            };

            var priceList = new PriceList();

            priceList.Apply(events);

            var ex = Assert.Throws <PriceList.CannotProvidePriceForUnknownSKU>(
                () => priceList.PriceFor("C"));

            Assert.Contains("price for C", ex.Message);
        }