public void Create_ReturnsVehicleWithDifferentIds_ForVehicles()
        {
            // Arrange
            VehicleAndFeeFactory sut = CreateSut();

            // Act
            var one   = sut.Create <IStandardCar>(DoesNotMatterWeight);
            var two   = sut.Create <ILuxuryCar>(DoesNotMatterWeight);
            var three = sut.Create <IMotorbike>(DoesNotMatterWeight);
            var four  = sut.Create <ITruck>(DoesNotMatterWeight);

            // Assert
            Assert.AreEqual(1,
                            one.Id,
                            "one.Id");
            Assert.AreEqual(2,
                            two.Id,
                            "two.Id");
            Assert.AreEqual(3,
                            three.Id,
                            "three.Id");
            Assert.AreEqual(4,
                            four.Id,
                            "four.Id");
        }
        public void Create_ReturnsVehicleWithDifferentIds_ForSameVehicleType()
        {
            // Arrange
            VehicleAndFeeFactory sut = CreateSut();

            // Act
            var one = sut.Create <ITruck>(DoesNotMatterWeight);
            var two = sut.Create <ITruck>(DoesNotMatterWeight);

            // Assert
            Assert.AreNotEqual(one.Id,
                               two.Id);
        }
Exemplo n.º 3
0
 private void CreateVehicles()
 {
     StandardCar    = VehicleAndFeeFactory.Create <IStandardCar>(DoesNotMatterWeightInKilogram);
     LuxuryCar      = VehicleAndFeeFactory.Create <ILuxuryCar>(DoesNotMatterWeightInKilogram);
     Motorbike      = VehicleAndFeeFactory.Create <IMotorbike>(DoesNotMatterWeightInKilogram);
     Truck          = VehicleAndFeeFactory.Create <ITruck>(101);
     MotorbikeOther = VehicleAndFeeFactory.Create <IMotorbike>(DoesNotMatterWeightInKilogram);
 }
        public void Create_ReturnsVehicleWithWeightFee_ForTruckAndHeavyVehicle()
        {
            // Arrange
            VehicleAndFeeFactory sut = CreateSut();

            // Act
            var actual = sut.Create <ITruck>(MinWeightInKilogramToForceWeightFee);

            // Assert
            Assert.True(actual.Fees.Any(x => x is IWeightFee));
        }
        public void Create_ReturnsVehicleWithVehicleFee_ForVehicleTypeTruck()
        {
            // Arrange
            VehicleAndFeeFactory sut = CreateSut();

            // Act
            var actual = sut.Create <ITruck>(DoesNotMatterWeight);

            // Assert
            Assert.True(actual.Fees.Any(x => x is IVehicleFee));
        }
        public void Create_ReturnsVehicle_WhenCalled()
        {
            // Arrange
            var factory = Substitute.For <IVehicleFactory>();
            VehicleAndFeeFactory sut = CreateSut(factory);

            // Act
            var actual = sut.Create <IStandardCar>(DefaultWeight);

            // Assert
            Assert.NotNull(actual,
                           "Should not be null!");
        }
        public void Create_ReturnsCallsVehicleFactory_WithGivenWeight()
        {
            // Arrange
            var factory = Substitute.For <IVehicleFactory>();
            VehicleAndFeeFactory sut = CreateSut(factory);

            // Act
            sut.Create <IStandardCar>(DefaultWeight);

            // Assert
            factory.Received().Create <IStandardCar>(1,
                                                     DefaultWeight);
        }
        public void Release_CallsVehicleFactory_WhenCalled()
        {
            // Arrange
            var vehicleFactory       = Substitute.For <IVehicleFactory>();
            var feeFactory           = Substitute.For <IFeesForVehicleFactory>();
            VehicleAndFeeFactory sut = CreateSut(vehicleFactory,
                                                 feeFactory);
            var vehicle = sut.Create <IStandardCar>(DefaultWeight);

            // Act
            sut.Release(vehicle);

            // Assert
            vehicleFactory.Received().Release(Arg.Any <IVehicle>());
        }
Exemplo n.º 9
0
        protected IVehicle CreateVehicle([NotNull] string vehicleTypeString,
                                         int weightInKilogram)
        {
            switch (vehicleTypeString)
            {
            case "StandardCar":
                return(VehicleAndFeeFactory.Create <IStandardCar>(weightInKilogram));

            case "LuxuryCar":
                return(VehicleAndFeeFactory.Create <ILuxuryCar>(weightInKilogram));

            case "Motorbike":
                return(VehicleAndFeeFactory.Create <IMotorbike>(weightInKilogram));

            case "Truck":
                return(VehicleAndFeeFactory.Create <ITruck>(weightInKilogram));

            default:
                throw new ArgumentException("Unknown vehivle type '{0}'!".Inject(vehicleTypeString));
            }
        }