Example #1
0
        public void Test1()
        {
            var options = new DbContextOptionsBuilder <MijnContext>()
                          .UseInMemoryDatabase("Naam")
                          .Options;
            var context = new MijnContext(options);

            context.Studenten.Add(new Student {
                Naam = "Bob"
            });
            context.Studenten.Add(new Student {
                Naam = "Bill"
            });
            context.Studenten.Add(new Student {
                Naam = "Jake"
            });
            context.Studenten.Add(new Student {
                Naam = "Alice"
            });
            context.Studenten.Add(new Student {
                Naam = "Joey"
            });

            context.SaveChanges();
            HomeController c      = new HomeController(context);
            var            result = Xunit.Assert.IsType <ViewResult>(c.Index());
            var            model  = Xunit.Assert.IsType <List <Student> >(result.Model);

            Xunit.Assert.True(model.Count == 5);
        }
Example #2
0
        public void Test2()
        {
            var options = new DbContextOptionsBuilder <MijnContext>()
                          .UseInMemoryDatabase("Naam")
                          .Options;
            var context = new MijnContext(options);

            context.Studenten.Add(new Student {
                Naam = "Bob"
            });
            context.Studenten.Add(new Student {
                Naam = "Bill"
            });
            context.Studenten.Add(new Student {
                Naam = "Jacob-Allexander"
            });
            context.Studenten.Add(new Student {
                Naam = "Alice"
            });
            context.Studenten.Add(new Student {
                Naam = "Joey"
            });

            context.SaveChanges();
            HomeController c = new HomeController(context);
        }
Example #3
0
        private MijnContext GetInMemoryDBMetData()
        {
            MijnContext context = GetNewInMemoryDatabase(true);

            AddStudentsInDb(context);
            return(GetNewInMemoryDatabase(false)); // gebruik een nieuw (clean) object voor de context
        }
Example #4
0
        private string databaseName; // zonder deze property kun je geen clean context maken.

        private void AddStudentsInDb(MijnContext context)
        {
            context.Add(new Student {
                studentNumber = 1, firstName = "Koen", email = "*****@*****.**"
            });
            context.Add(new Student {
                studentNumber = 2, firstName = "Robin", email = "*****@*****.**"
            });
            context.Add(new Student {
                studentNumber = 3, firstName = "Binh", email = "*****@*****.**"
            });
            context.Add(new Student {
                studentNumber = 4, firstName = "Mehdi", email = "*****@*****.**"
            });
            context.Add(new Student {
                studentNumber = 5, firstName = "Klaas", email = "*****@*****.**"
            });
            context.SaveChanges();
        }
Example #5
0
 public HomeController(MijnContext context_)
 {
     context = context_;
 }
 public StudentController(MijnContext context)
 {
     this.context = context;
 }
Example #7
0
 public HomeController(MijnContext context)
 {
     this.context = context;
 }
 public StudentAdministratieController(MijnContext context)
 {
     this.context = context;
 }
Example #9
0
 public StudentsController(MijnContext context) : base(context)
 {
 }
Example #10
0
 public HomeController(MijnContext context) : base(context)
 {
 }