示例#1
0
        public List <IProduct> Add(ProductRequest productRequest, ILocation location)
        {
            if (!productRequest.Name.Equals(new PizzaProductName()))
            {
                return(_nextStrategy.Add(productRequest, location));
            }

            IProductSize size = _sizeMap.DomainSize(productRequest.Size);

            _products.Add(new Pizza(size, productRequest.Ingredients.Select(i => _ingredientMap.DomainIngredient(i, new Pizza(size), location)).ToArray()));
            return(_products);
        }
示例#2
0
        public void GivenNonExistentSizeName_WhenAskingToMap_ThenItShouldThrow()
        {
            // arrange
            const string name    = "Dammit, Bobby!";
            SizeMap      sizeMap = new SizeMap();

            // act
            Action action = () => sizeMap.DomainSize(name);

            // assert
            action.Should().Throw <Exception>();
        }
示例#3
0
        public void GivenLargeSizeName_WhenAskingToMap_ThenItShouldReturnCorrectSize()
        {
            // arrange
            const string name    = "Large";
            SizeMap      sizeMap = new SizeMap();

            // act
            IProductSize mappedSize = sizeMap.DomainSize(name);

            // assert
            ((decimal)mappedSize.Price()).Should().Be(18.0m);
        }
示例#4
0
        public void GivenAlternativeSizeName_WhenAskingToMap_ThenItShouldReturnCorrectSize()
        {
            // arrange
            const string name    = "Mini";
            SizeMap      sizeMap = new SizeMap();

            // act
            IProductSize actual = sizeMap.DomainSize(name);

            // assert
            actual.GetType().Name.Should().Be(nameof(MiniPizzaSize));
        }