Ejemplo n.º 1
0
        public void ShouldExecuteForMultipleItemsSuccessFully()
        {
            // Arrange
            _basicTariff.Setup(x => x.Calculate(It.IsAny <double>())).Returns(new Product
            {
                Consumption = 500,
                TariffType  = TariffType.BasicTariff,
                AnnualCost  = 500
            });
            _packagedTariff.Setup(x => x.Calculate(It.IsAny <double>())).Returns(new Product
            {
                Consumption = 500,
                TariffType  = TariffType.PackagedTariff,
                AnnualCost  = 500
            });

            _tariffComparer = new TariffComparer(_basicTariff.Object, _packagedTariff.Object);

            // Act
            _tariffComparer.Compare(new double[] { 500, 800 });

            // Assert
            _basicTariff.Verify(x => x.Calculate(It.IsAny <double>()), Times.Exactly(2));
            _packagedTariff.Verify(x => x.Calculate(It.IsAny <double>()), Times.Exactly(2));
        }
Ejemplo n.º 2
0
        public void ShouldThrowException()
        {
            // Arrange
            _basicTariff.Setup(x => x.Calculate(It.IsAny <double>())).Throws(new ArgumentException());
            _packagedTariff.Setup(x => x.Calculate(It.IsAny <double>())).Throws(new ArgumentException());

            _tariffComparer = new TariffComparer(_basicTariff.Object, _packagedTariff.Object);

            // Act
            _tariffComparer.Compare(new double[] { 500, 800 });

            // Assert - Expects Exception
        }