Esempio n. 1
0
        public void DoitLeverUneException_SiPasDeWagonDeMarchandise()
        {
            var train = new Train(new Locomotive(Poids.Kg(10)));

            Assert.Throws <InvalidOperationException>(() =>
                                                      train.Charger(new Avoine(), Volume.M3(10)));
        }
Esempio n. 2
0
        public void UnChargementAvecUnVolumeSupérieurAuVolumeMax_DoitLeverUneException()
        {
            var wagon = new Wagon <Céréale>(Poids.Tonnes(20), Volume.M3(100));

            Assert.Throws <InvalidOperationException>(() =>
                                                      wagon.Charger(new Avoine(), Volume.M3(200)));
        }
Esempio n. 3
0
        public void UnChargementAvecUnVolumeInférieurAuVolumeRestant_DoitAjouterCeVolume()
        {
            var wagon = new Wagon <Céréale>(Poids.Tonnes(20), Volume.M3(100));

            wagon.Charger(new Avoine(), Volume.M3(50));

            Assert.Equal(Volume.M3(50), wagon.VolumeUtilisé);
        }
Esempio n. 4
0
        public void AssignerUnWagonQuiDépasseLaCapacitéDeTraction_DoitLeverUneException()
        {
            var train = new Train(new Locomotive(Poids.Kg(10)));

            Assert.Throws <InvalidOperationException>(() =>
                                                      train.Assigner(
                                                          new Wagon <Avoine>(Poids.Tonnes(1), Volume.M3(10))));
        }
Esempio n. 5
0
        public Locomotive(Poids capacitéDeTraction)
        {
            if (capacitéDeTraction <= Poids.Zéro)
            {
                throw new InvalidOperationException();
            }

            CapacitéDeTraction = capacitéDeTraction;
        }
Esempio n. 6
0
        public void DoitLeverUneException_SiOnPeutChargerLeVolume_MaisQueLePoidsTotalDépasseLaCapacitéDeTraction()
        {
            var train = new Train(new Locomotive(Poids.Tonnes(1000)));

            train.Assigner(new Wagon <Avoine>(Poids.Tonnes(20), Volume.M3(20000)));

            Assert.Throws <InvalidOperationException>(() =>
                                                      train.Charger(new Avoine(), Volume.M3(10000)));
        }
Esempio n. 7
0
        public void DoitLeverUneException_SiPlusDePlaceDisponibleDansLesWagonsDuTypeDemandé()
        {
            var train = new Train(new Locomotive(Poids.Tonnes(1000)));

            train.Assigner(new Wagon <Avoine>(Poids.Tonnes(20), Volume.M3(20)));

            Assert.Throws <InvalidOperationException>(() =>
                                                      train.Charger(new Avoine(), Volume.M3(100)));
        }
Esempio n. 8
0
        public void DoitLeverUneException_SiPasDeWagonDeLaMarchandiseDemandée()
        {
            var train = new Train(new Locomotive(Poids.Tonnes(1000)));

            train.Assigner(new Wagon <Avoine>(Poids.Tonnes(20), Volume.M3(20)));

            Assert.Throws <InvalidOperationException>(() =>
                                                      train.Charger(new Ciment(), Volume.M3(10)));
        }
Esempio n. 9
0
        public void DoitPouvoirChargerUneMarchandise_SIlResteDeLaPlaceDansUnWagon()
        {
            var train = new Train(new Locomotive(Poids.Tonnes(1000)));

            train.Assigner(new Wagon <Avoine>(Poids.Tonnes(20), Volume.M3(20)));

            train.Charger(new Avoine(), Volume.M3(10));
            var actual = train.VolumeTotalUtilisé <Avoine>();

            Assert.Equal(Volume.M3(10), actual);
        }
Esempio n. 10
0
        protected Wagon(Poids poidsÀVide, Volume volumeMax)
        {
            if (poidsÀVide <= Poids.Zéro)
            {
                throw new InvalidOperationException("Le poids doit être strictement positif");
            }

            if (volumeMax <= Volume.Zéro)
            {
                throw new InvalidOperationException("Le volume max doit être strictement positif");
            }

            PoidsÀVide = poidsÀVide;
            VolumeMax  = volumeMax;

            VolumeUtilisé = Volume.Zéro;
        }
        public DefaultNHibernatePatternsHolder(IDomainInspector domainInspector, IExplicitDeclarationsHolder explicitDeclarations)
        {
            Poids.Add(new PoIdPattern());
            Sets.Add(new SetCollectionPattern());
            Bags.Add(new BagCollectionPattern());
            Lists.Add(new ListCollectionPattern(domainInspector));
            Arrays.Add(new ArrayCollectionPattern());
            Components.Add(new ComponentPattern(domainInspector));
            Dictionaries.Add(new DictionaryCollectionPattern());

            PoidStrategies.Add(new HighLowPoidPattern());
            PoidStrategies.Add(new GuidOptimizedPoidPattern());

            PersistentPropertiesExclusions.Add(new ReadOnlyPropertyPattern());
            ManyToOneRelations.Add(new OneToOneUnidirectionalToManyToOnePattern(domainInspector, explicitDeclarations));
            ManyToOneRelations.Add(new PolymorphicManyToOnePattern(domainInspector));
            OneToManyRelations.Add(new PolymorphicOneToManyPattern(domainInspector));
            HeterogeneousAssociations.Add(new HeterogeneousAssociationOnPolymorphicPattern(domainInspector));
        }
Esempio n. 12
0
        public DefaultNHibernatePatternsHolder(IDomainInspector domainInspector, IExplicitDeclarationsHolder explicitDeclarations)
        {
            if (domainInspector == null)
            {
                throw new ArgumentNullException("domainInspector");
            }
            Poids.Add(new PoIdPattern());
            Sets.Add(new SetCollectionPattern());
            Bags.Add(new BagCollectionPattern());
            Lists.Add(new ListCollectionPattern(domainInspector));
            Arrays.Add(new ArrayCollectionPattern());
            Components.Add(new ComponentPattern(domainInspector));
            Dictionaries.Add(new DictionaryCollectionPattern());

            PoidStrategies.Add(new HighLowPoidPattern());
            PoidStrategies.Add(new GuidOptimizedPoidPattern());

            PersistentPropertiesExclusions.Add(new ReadOnlyPropertyPattern());
            ManyToOneRelations.Add(new OneToOneUnidirectionalToManyToOnePattern(explicitDeclarations));
        }
Esempio n. 13
0
 public void UnWagonAvecUnVolumeMaxÀZero_DoitLeverUneException()
 {
     Assert.Throws <InvalidOperationException>(() =>
                                               new Wagon <Céréale>(Poids.Tonnes(20), Volume.Zéro));
 }
 public virtual bool IsPersistentId(MemberInfo member)
 {
     return(Poids.Contains(member));
 }
Esempio n. 15
0
 public Blé() : base(Poids.Kg(600))
 {
 }
Esempio n. 16
0
 protected Marchandise(Poids poidsParM3)
 {
     PoidsParM3 = poidsParM3;
 }
Esempio n. 17
0
 protected Céréale(Poids poidsParM3)
     : base(poidsParM3)
 {
 }
Esempio n. 18
0
 public Ciment() : base(Poids.Kg(2500))
 {
 }
Esempio n. 19
0
 public Avoine() : base(Poids.Kg(500))
 {
 }