コード例 #1
0
        public void ToevoegenDocent_DocentZonderLand_DocentHeeftLandBE()
        {
            //Arrange
            //var options = new DbContextOptionsBuilder<EFOpleidingenContext>()
            //    .UseInMemoryDatabase($"InMemoryDatabase{Guid.NewGuid()}")
            //    .Options;

            using var context = new EFOpleidingenContext(options);

            context.Landen.Add(new Land()
            {
                LandCode = "BE",
                Naam     = "Belgie"
            });

            context.SaveChanges();

            var docent = new Docent()
            {
                DocentId    = 20,
                Voornaam    = "Fanny",
                Familienaam = "Kiekeboe",
                Wedde       = 10100,
                InDienst    = new DateTime(2019, 1, 1),
                CampusId    = 1
            };

            //Act
            var docentService = new DocentService(context);

            docentService.ToevoegenDocent(docent);
            context.SaveChanges();

            //Assert
            var testDocent = docentService.GetDocent(20);

            Assert.AreEqual("BE", testDocent.LandCode);
        }