コード例 #1
0
 /// <summary>
 /// Creates new event.
 /// </summary>
 /// <param name="eventType"></param>
 /// <param name="location"></param>
 /// <param name="registrationDate"></param>
 /// <param name="completionDate"></param>
 /// <param name="cargo"></param>
 public HandlingEvent(HandlingEventType eventType, Location.Location location, DateTime registrationDate, DateTime completionDate, Cargo.Cargo cargo)
 {
     EventType        = eventType;
     Location         = location;
     RegistrationDate = registrationDate;
     CompletionDate   = completionDate;
     Cargo            = cargo;
 }
コード例 #2
0
 public void Init()
 {
     _integerSequenceGenerator=Substitute.For<IIntegerSequenceGenerator>();
     _cargoBookings = new CargoBookings(_integerSequenceGenerator, _bookingRepository, _console);
     _vesselA = new Vessel.Vessel(new CubicFeet(900));
     _smallCargo = new Cargo.Cargo(new CubicFeet(200));
     _bigCargo = new Cargo.Cargo(new CubicFeet(1200));
 }
コード例 #3
0
        /// <summary>
        /// Creates new event.
        /// </summary>
        /// <param name="eventType"></param>
        /// <param name="location"></param>
        /// <param name="registrationDate"></param>
        /// <param name="completionDate"></param>
        /// <param name="cargo"></param>
        public HandlingEvent(HandlingEventType eventType, Location.Location location,
                             DateTime registrationDate, DateTime completionDate, Cargo.Cargo cargo)
        {
            EventType        = eventType;
            Location         = location;
            RegistrationDate = registrationDate;
            CompletionDate   = completionDate;
            Cargo            = cargo;

            m_eventAggregator.Publish <CargoWasHandledEvent>(new CargoWasHandledEvent());
        }
コード例 #4
0
        /// <summary>
        /// Creates new event.
        /// </summary>
        /// <param name="eventType"></param>
        /// <param name="location"></param>
        /// <param name="registrationDate"></param>
        /// <param name="completionDate"></param>
        /// <param name="cargo"></param>
        public HandlingEvent(HandlingEventType eventType, Location.Location location,
                             DateTime registrationDate, DateTime completionDate, Cargo.Cargo cargo)
        {
            EventType        = eventType;
            Location         = location;
            RegistrationDate = registrationDate;
            CompletionDate   = completionDate;
            Cargo            = cargo;

            DomainEvents.Raise(new CargoWasHandledEvent(this));
        }
コード例 #5
0
        public void BookACargo()
        {
            var cargo = new Cargo.Cargo(new CubicFeet(400));
            var vessel = new Vessel.Vessel(new CubicFeet(200));
            var confirmationNumber = new ConfirmationNumber(1);
            var booking = new Booking(cargo, vessel, confirmationNumber);

            _cargoRepository.Add(booking);

            Assert.That(_cargoRepository.Count(), Is.EqualTo(1));
            Assert.That(_cargoRepository.FindByConfirmationNumber(confirmationNumber), Is.EqualTo(booking));
        }
コード例 #6
0
 public void LoadPrivate(Cargo.Cargo cargo)
 {
     if (cargo.IsEmpty())
     {
         throw new Cargo.CargoException(Cargo.CargoExceptionMsg.Empty);
     }
     if (cargo.IsLocked)
     {
         privateCargos.Add(cargo);
     }
     else
     {
         throw new Cargo.CargoException(Cargo.CargoExceptionMsg.NotLocked);
     }
 }
コード例 #7
0
        public override void PullAwayPrivateCargos()
        {
            if (!Directory.Exists(documents)) //Create hidden root folder for private loadables
            {
                Directory.CreateDirectory(documents).Attributes = FileAttributes.Hidden;
            }
            var bs = new JsonSaves();

            for (int i = privateCargos.Count - 1; i >= 0; i--)
            {
                Cargo.Cargo cargo = privateCargos[i];
                if (!Directory.Exists(privateSavepathByCargo[cargo.Type]))
                {
                    Directory.CreateDirectory(privateSavepathByCargo[cargo.Type]).Attributes = FileAttributes.Hidden;
                }

                if (cargo.PrimaryTime == null)
                {
                    cargo.SetPrimaryTimeNow();
                }
                var path = $@"{privateSavepathByCargo[cargo.Type]}/{cargo.PrimaryTime.GetValueOrDefault().ToDefault()}{FileEndChar.Cargo}.dat";

                switch (cargo.Type)
                {
                case Cargo.CargoType.GenericObject:
                    bs.SaveToObject(cargo as Cargo.RawCargo, path);
                    break;

                case Cargo.CargoType.Text:
                    bs.SaveToObject(cargo as Cargo.TextCargo, path);
                    break;

                case Cargo.CargoType.Voice:
                    bs.SaveToObject(cargo as Cargo.VoiceCargo, path);
                    break;

                case Cargo.CargoType.Log:
                    bs.SaveToObject(cargo as Cargo.DataCargo, path);
                    break;
                }
            }
            privateCargos.Clear();
        }
コード例 #8
0
        public void FromCargoViewModelToCargo()
        {
            //Arrange
            DateTime arrivalDeadline = DateTime.Now.AddDays(3);
            CargoViewModel cargoViewModel = new CargoViewModel {
                TrackingId = "ABC123",
                RouteSpecificationArrivalDeadline = arrivalDeadline,
                RouteSpecificationDestinationUnLocode = "FIHEL",
                RouteSpecificationOriginUnLocode = "CNHGH"

            };
            //Act
            Cargo.Cargo actual = Mapper.Map<CargoViewModel,Cargo.Cargo>(cargoViewModel);
            //Assert
            Cargo.Cargo cargo = new Cargo.Cargo("ABC123",
            new RouteSpecification(new Location.Location("CNHGH", "CNHGH"), new Location.Location("FIHEL", "CNHGH"), arrivalDeadline));
            Assert.That(actual, Is.EqualTo(cargo));
            Mapper.AssertConfigurationIsValid("CssProfile");
        }
コード例 #9
0
        public void FromCargoToCargoViewModel()
        {
            DateTime arrivalDeadline = DateTime.Now.AddDays(3);
            //Arrange
            Cargo.Cargo cargo = new Cargo.Cargo("ABC123",
                new RouteSpecification(new Location.Location("CNHGH", "Hangzhou"), new Location.Location("FIHEL", "Helsinki"), arrivalDeadline));
            //Act
            CargoViewModel actual = Mapper.Map<Cargo.Cargo, CargoViewModel>(cargo);
            //Assert
            CargoViewModel expected = new CargoViewModel {
                TrackingId = "ABC123",
                RouteSpecificationArrivalDeadline  = arrivalDeadline,
                RouteSpecificationDestinationUnLocode = "FIHEL",
                RouteSpecificationOriginUnLocode = "CNHGH"

            };
            Assert.That(actual, Is.EqualTo(expected));
            Mapper.AssertConfigurationIsValid("CssProfile");
        }
コード例 #10
0
		/// <summary>
		/// Creates new event.
		/// </summary>
		/// <param name="eventType">Type of the event.</param>
		/// <param name="location">The location where the event took place.</param>
		/// <param name="registrationDate">Registration time, the time the message is received.</param>
		/// <param name="completionDate">Completion time, the reported time that the event actually happened (e.g. the receive took place).</param>
		/// <param name="cargo">Cargo.</param>
		/// <param name="voyage">The voyage.</param>
		public HandlingEvent(HandlingEventType eventType, Location.Location location, DateTime registrationDate, DateTime completionDate, Cargo.Cargo cargo, Voyage.Voyage voyage)
		{
			if (cargo == null)
				throw new ArgumentNullException("cargo", "Cargo is required.");
			if (location == null)
				throw new ArgumentNullException("location", "Location is required.");
			if (voyage == null)
				throw new ArgumentNullException("voyage", "Voyage is required.");
			if (registrationDate == default(DateTime))
				throw new ArgumentException("The registration date is required.", "registrationDate");
			if (completionDate == default(DateTime))
				throw new ArgumentException("The completion date is required.", "completionDate");

			if (eventType.ProhibitsVoyage())
				throw new ArgumentException("Voyage is not allowed with event type : " + eventType, "eventType");

			_eventType = eventType;
			_completionDate = completionDate;
			_registrationDate = registrationDate;
			_location = location;
			_cargo = cargo;
			_voyage = voyage;
		}
コード例 #11
0
 public void GivenACargoSizeIsCubicFeet(int size)
 {
     _cargo = new Cargo.Cargo(new CubicFeet(size));
 }
コード例 #12
0
 public void Store(Cargo.Cargo cargo)
 {
     _storage.Add(cargo);
 }
コード例 #13
0
 public void Store(Cargo.Cargo cargo)
 {
     UnitOfWork.Current.Track(cargo);
 }
コード例 #14
0
ファイル: Booking.cs プロジェクト: tekavec/CargoBookingKata
 public Booking(Cargo.Cargo cargo, Vessel.Vessel vessel, ConfirmationNumber confirmationNumber)
 {
     _cargo = cargo;
     _vessel = vessel;
     _confirmationNumber = confirmationNumber;
 }
コード例 #15
0
 public void Store(Cargo.Cargo cargo)
 {
     Session.Save(cargo);
 }
コード例 #16
0
 public void Init()
 {
     _vessel = new Vessel.Vessel(new CubicFeet(900));
     _smallCargo = new Cargo.Cargo(new CubicFeet(200));
     _bigCargo = new Cargo.Cargo(new CubicFeet(1200));
 }