コード例 #1
0
        public void Insert_Should_InsertArtikel_When_NieuwArtikel_IsGiven()
        {
            // Arrange
            BevestigdeBestelling bevestigdeBestelling = new BevestigdeBestellingBuilder().SetDummy().Create();

            // Act
            _target.Insert(bevestigdeBestelling);

            BevestigdeBestelling result = _target.GetByFactuurnummer(bevestigdeBestelling.Factuurnummer);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(bevestigdeBestelling.IsEqual(result));
        }
コード例 #2
0
        public void Insert_ShouldInsertNewBestellingIntoTheDatabase()
        {
            // Arrange
            var bestelling = new Bestelling()
            {
                Klantnummer          = 1,
                FactuurTotaalInclBtw = 200.0m,
                FactuurTotaalExclBtw = 188.88m,
                Factuurnummer        = 1,
                BestelStatus         = BestelStatus.Goedgekeurd,
                Besteldatum          = DateTime.Now,
                BestelRegels         = _bestellingBuilder.SetDummyBestelRegels().ToList()
            };

            // Act
            _target.Insert(bestelling);

            // Assert
            var result = _betaalContext.Bestellingen.SingleOrDefault(b => b.Factuurnummer == 1);

            Assert.AreEqual(2, result.BestelRegels.Count);
            Assert.AreEqual(1, result.Klantnummer);
            Assert.AreEqual(200.0m, result.FactuurTotaalInclBtw);
            Assert.AreEqual(BestelStatus.Goedgekeurd, result.BestelStatus);
        }
        public void Insert_ShouldNotInsertArtikelInDatabase_When_AnExistingFactuurnummer_IsGiven()
        {
            // Arrange
            Bestelling bestelling1 = new BestellingBuilder().SetDummy()
                                     .SetFactuurnummer(1)
                                     .Create();
            Bestelling bestelling2 = new BestellingBuilder().SetDummy()
                                     .SetFactuurnummer(1)
                                     .Create();

            var dataMapper = new BestellingDataMapper(_context);

            // Act
            dataMapper.Insert(bestelling1);

            void Act()
            {
                dataMapper.Insert(bestelling2);
            }

            // Assert
            Assert.ThrowsException <DbUpdateException>((Action)Act);
        }
        public void Insert_Should_InsertArtikel_When_NieuwArtikel_IsGiven()
        {
            // Arrange
            Bestelling bestelling = new BestellingBuilder().SetDummy().Create();

            var dataMapper = new BestellingDataMapper(_context);

            // Act
            dataMapper.Insert(bestelling);

            Bestelling result = dataMapper.GetByFactuurnummer(bestelling.Factuurnummer);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(bestelling.IsEqual(result));
        }
        public void Update_ShouldUpdateBestelling_When_AnUpdatedBestelling_IsGiven()
        {
            // Arrange
            Bestelling bestelling       = new BestellingBuilder().SetDummy().Create();
            Bestelling bestellingUpdate = bestelling;

            bestellingUpdate.BestelStatus = BestelStatus.Goedgekeurd;

            var dataMapper = new BestellingDataMapper(_context);

            dataMapper.Insert(bestelling);

            // Act
            dataMapper.Update(bestellingUpdate);
            Bestelling result = dataMapper.GetByFactuurnummer(bestellingUpdate.Factuurnummer);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.IsEqual(bestellingUpdate));
        }
        public void Insert_ShouldNotInsertArtikelInDatabase_When_NoKlantNummer_IsGiven()
        {
            // Arrange
            Bestelling bestelling = new BestellingBuilder()
                                    .SetBesteldatum(DateTime.Now)
                                    .SetBestelStatus(BestelStatus.Geplaatst)
                                    .SetFactuurnummer(1)
                                    .Create();

            var dataMapper = new BestellingDataMapper(_context);

            // Act
            void Act()
            {
                dataMapper.Insert(bestelling);
            }

            // Assert
            Assert.ThrowsException <ArgumentNullException>((Action)Act);
        }