Ejemplo n.º 1
0
 public void ShouldReturnCorrectPrice()
 {
     var expected = 8;
     ItemPricing pricing = new ItemPricing(new BatchPricing(3, 4), 2);
     var actual = sut.Calculate(5, pricing);
     Assert.Equal(expected, actual);
 }
        public void ShouldSetPricing_if_SetPricingMessageIsReceived()
        {
            var expectedPricing = new ItemPricing(new BatchPricing(3, 2), 1);

            sut.Tell(new SetPricingMessage(expectedPricing));

            Assert.Equal(expectedPricing, sut.UnderlyingActor.Pricing);
        }
Ejemplo n.º 3
0
        public double Calculate(int amount, ItemPricing pricing)
        {
            double batches = pricing.Batch.Quantity == 0 ? 0 : Math.Floor(Convert.ToDouble(amount / pricing.Batch.Quantity));

            double leftovers = amount - (batches * pricing.Batch.Quantity);

            return (batches * pricing.Batch.Price) + (leftovers * pricing.PerSingle);
        }
        public void ShouldReturnResult_If_CalculateMessageIsReceived()
        {
            var expectedPrice = 1;

            string id = "A";
            calcMock.Setup(x => x.Calculate(It.IsAny<int>(), It.IsAny<ItemPricing>())).Returns(expectedPrice);
            var scanMessage = new ScanMessage(id);
            var pricing = new ItemPricing(new BatchPricing(3, 2), 1);

            sut.Tell(new SetPricingMessage(pricing));
            sut.Tell(scanMessage);

            sut.Tell(new CalculateMessage(true));
            var actual = ExpectMsg<double>();

            Assert.Equal(expectedPrice, actual);
        }
Ejemplo n.º 5
0
 public void HandlePricingMessage(SetPricingMessage message)
 {
     _pricing = message.Pricing;
 }
Ejemplo n.º 6
0
 public SetPricingMessage(ItemPricing pricing)
 {
     Pricing = pricing;
 }