Exemplo n.º 1
0
        public Car Create(ICurrentCaller caller, int year, string make, string model)
        {
            caller.GuardAgainstNull(nameof(caller));

            var owner = this.personsService.Get(caller.Id)
                        .ToOwner();

            var car = new CarEntity(this.recorder, this.idFactory);

            car.SetOwnership(new VehicleOwner(owner.Id));
            car.SetManufacturer(new Manufacturer(year, make, model));

            var created = this.storage.Save(car);

            this.recorder.TraceInformation("Car {Id} was created by {Caller}", created.Id, caller.Id);

            return(created.ToCar());
        }
Exemplo n.º 2
0
        public void WhenReserve_ThenReservesCar()
        {
            var fromUtc = DateTime.UtcNow.AddMinutes(1);
            var toUtc   = fromUtc.AddMinutes(1);
            var entity  = new CarEntity(this.recorder.Object, this.idFactory.Object);

            entity.SetManufacturer(new Manufacturer(2010, Manufacturer.Makes[0], Manufacturer.Models[0]));
            entity.SetOwnership(new VehicleOwner("anownerid"));
            entity.Register(new LicensePlate(LicensePlate.Jurisdictions[0], "anumber"));
            this.storage.Setup(s => s.Load(It.Is <Identifier>(i => i == "acarid")))
            .Returns(entity);
            this.storage.Setup(s => s.Save(It.Is <CarEntity>(e => e.Unavailabilities.Count == 1)))
            .Returns(entity);

            var result = this.carsApplication.Offline(this.caller.Object, "acarid", fromUtc, toUtc);

            result.Should().NotBeNull();
        }