public void AddRangeMetCheckOpAlBestaandeCombinatieCursusInstantie()
        {
            using (var repo = new CursusInstantieRepository(new DatabaseContext(_options)))
            {
                repo.InsertRange(new List <CursusInstantie>()
                {
                    new CursusInstantie()
                    {
                        CursusId   = "C1",
                        StartDatum = new DateTime(2016, 10, 15),
                    },
                    new CursusInstantie()
                    {
                        CursusId   = "C1",
                        StartDatum = new DateTime(2016, 10, 15),
                    },
                });
            }

            using (var repo = new CursusInstantieRepository(new DatabaseContext(_options)))
            {
                var result = repo.FindAll();
                Assert.AreEqual(1, repo.Count());
            }
        }
        public void AddRangeCursusInstantie()
        {
            int numberOfSavedChanges = 0;

            using (var repo = new CursusInstantieRepository(new DatabaseContext(_options)))
            {
                numberOfSavedChanges = repo.InsertRange(new List <CursusInstantie>()
                {
                    new CursusInstantie()
                    {
                        CursusId   = "C1",
                        StartDatum = new DateTime(2016, 10, 15),
                    },
                    new CursusInstantie()
                    {
                        CursusId   = "C2",
                        StartDatum = new DateTime(2016, 11, 15),
                    },
                });
            }

            using (var repo = new CursusInstantieRepository(new DatabaseContext(_options)))
            {
                var result = repo.FindAll();
                Assert.AreEqual(2, repo.Count());
                Assert.AreEqual(2, numberOfSavedChanges);
            }
        }
        public void TestFindByDatumRangeCursusInstantie()
        {
            using (var repo = new CursusInstantieRepository(new DatabaseContext(_options)))
            {
                repo.InsertRange(new List <CursusInstantie>()
                {
                    new CursusInstantie()
                    {
                        CursusId   = "C1",
                        StartDatum = new DateTime(2016, 10, 15),
                        Cursus     = new Cursus()
                        {
                            Code  = "C1",
                            Dagen = 2,
                            Titel = "Cursus 1"
                        },
                    },
                    new CursusInstantie()
                    {
                        CursusId   = "C1",
                        StartDatum = new DateTime(2016, 11, 15),
                        Cursus     = new Cursus()
                        {
                            Code  = "C1",
                            Dagen = 2,
                            Titel = "Cursus 1"
                        },
                    },
                    new CursusInstantie()
                    {
                        CursusId   = "C1",
                        StartDatum = new DateTime(2016, 10, 12),
                        Cursus     = new Cursus()
                        {
                            Code  = "C1",
                            Dagen = 2,
                            Titel = "Cursus 1"
                        },
                    },
                });
            }

            using (var repo = new CursusInstantieRepository(new DatabaseContext(_options)))
            {
                var startDate = new DateTime(2016, 10, 11);
                var endDate   = new DateTime(2016, 10, 17);
                var result    = repo.FindBy(instantie => instantie.StartDatum >= startDate && instantie.StartDatum <= endDate);

                Assert.AreEqual(2, result.Count());
                Assert.AreEqual(10, result.FirstOrDefault().StartDatum.Month);
                Assert.IsTrue(result.FirstOrDefault().StartDatum.Day >= 11 && result.FirstOrDefault().StartDatum.Day <= 17);
            }
        }
        public void AddRangeMetCheckOpNietBestaandeCursusEnAutomatischToevoegenCursusInstantie()
        {
            using (var repo = new CursusInstantieRepository(new DatabaseContext(_options)))
            {
                repo.InsertRange(new List <CursusInstantie>()
                {
                    new CursusInstantie()
                    {
                        CursusId   = "C1",
                        StartDatum = new DateTime(2016, 10, 15),
                        Cursus     = new Cursus()
                        {
                            Code  = "C1",
                            Dagen = 2,
                            Titel = "Cursus 1"
                        },
                    },
                    new CursusInstantie()
                    {
                        CursusId   = "C1",
                        StartDatum = new DateTime(2016, 11, 15),
                        Cursus     = new Cursus()
                        {
                            Code  = "C1",
                            Dagen = 2,
                            Titel = "Cursus 1"
                        },
                    },
                });
            }

            using (var repo = new CursusInstantieRepository(new DatabaseContext(_options)))
            {
                var result = repo.FindAll();
                Assert.AreEqual(2, repo.Count());
            }

            using (var repo = new CursusRepository(new DatabaseContext(_options)))
            {
                var result = repo.Find("C1");
                Assert.AreEqual(1, repo.Count());

                Assert.AreEqual(2, result.Dagen);
                Assert.AreEqual("Cursus 1", result.Titel);
                Assert.AreEqual("C1", result.Code);
            }
        }
        public void TestFindByCursusInstantieMetCursus()
        {
            using (var repo = new CursusInstantieRepository(new DatabaseContext(_options)))
            {
                repo.InsertRange(new List <CursusInstantie>()
                {
                    new CursusInstantie()
                    {
                        CursusId   = "C1",
                        StartDatum = new DateTime(2016, 10, 15),
                        Cursus     = new Cursus()
                        {
                            Code  = "C1",
                            Dagen = 2,
                            Titel = "Cursus 1"
                        },
                    },
                    new CursusInstantie()
                    {
                        CursusId   = "C1",
                        StartDatum = new DateTime(2016, 11, 15),
                        Cursus     = new Cursus()
                        {
                            Code  = "C1",
                            Dagen = 2,
                            Titel = "Cursus 1"
                        },
                    },
                });
            }

            using (var repo = new CursusInstantieRepository(new DatabaseContext(_options)))
            {
                var startDate = new DateTime(2016, 10, 11);
                var endDate   = new DateTime(2016, 10, 17);
                var result    = repo.FindBy(instantie => instantie.StartDatum >= startDate && instantie.StartDatum <= endDate)
                                .FirstOrDefault();

                Assert.AreEqual("C1", result.CursusId);
                Assert.AreEqual("C1", result.Cursus.Code);
                Assert.AreEqual(2, result.Cursus.Dagen);
                Assert.AreEqual("Cursus 1", result.Cursus.Titel);
                Assert.AreEqual(new DateTime(2016, 10, 15), result.StartDatum);
            }
        }