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

            Assert.Throws <InvalidOperationException>(() =>
                                                      train.Charger(new Avoine(), Volume.M3(10)));
        }
Exemple #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)));
        }
Exemple #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é);
        }
        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))));
        }
        public Locomotive(Poids capacitéDeTraction)
        {
            if (capacitéDeTraction <= Poids.Zéro)
            {
                throw new InvalidOperationException();
            }

            CapacitéDeTraction = capacitéDeTraction;
        }
        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)));
        }
        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)));
        }
        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)));
        }
        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);
        }
Exemple #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));
        }
Exemple #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));
        }
Exemple #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));
 }
Exemple #15
0
 public Blé() : base(Poids.Kg(600))
 {
 }
Exemple #16
0
 protected Marchandise(Poids poidsParM3)
 {
     PoidsParM3 = poidsParM3;
 }
Exemple #17
0
 protected Céréale(Poids poidsParM3)
     : base(poidsParM3)
 {
 }
Exemple #18
0
 public Ciment() : base(Poids.Kg(2500))
 {
 }
Exemple #19
0
 public Avoine() : base(Poids.Kg(500))
 {
 }