示例#1
0
        public void XmlRepo_can_add_2_Infektion_gleiches_Land()
        {
            var repo = new XmlRepository();

            var l = new Land()
            {
                Name = "Seuchenland"
            };

            var inf1 = new Infektion()
            {
                Person = "Bernd"
            };

            inf1.Wohnort = new Region()
            {
                Name = "Pesttal", Land = l
            };
            var inf2 = new Infektion()
            {
                Person = "Bernd"
            };

            inf2.Wohnort = new Region()
            {
                Name = "Rotzberg", Land = l
            };

            repo.Add(inf1);
            repo.Add(inf2);
            repo.SaveAll();
        }
示例#2
0
        public void XmlRepo_can_add_2_Infektion_und_unabhägige_Laender()
        {
            var repo = new XmlRepository();

            var inf1 = new Infektion()
            {
                Person = "Bernd"
            };
            var inf2 = new Infektion()
            {
                Person = "Brot"
            };

            var land = new Land()
            {
                Name = "Pestland"
            };
            var land2 = new Land()
            {
                Name = "Seuchenland"
            };

            land2.Region.Add(new Region()
            {
                Name = "Todeszones"
            });

            repo.Add(inf1);
            repo.Add(inf2);
            repo.Add(land);
            repo.Add(land2);
            repo.SaveAll();
        }
示例#3
0
        public void XmlRepo_can_add_Infektion_with_2_Virus_MitLand()
        {
            var repo = new XmlRepository();
            var inf  = new Infektion()
            {
                Person = "Bernd"
            };

            inf.Viren.Add(new Virus()
            {
                Name = "v1"
            });
            inf.Viren.Add(new Virus()
            {
                Name = "v2"
            });
            var l = new Land()
            {
                Name = "Seuchenland"
            };

            inf.Wohnort = new Region()
            {
                Name = "Pesttal", Land = l
            };

            repo.Add(inf);
            repo.SaveAll();
        }
示例#4
0
        public void XmlRepo_can_add_Infektion()
        {
            var repo = new XmlRepository();
            var inf  = new Infektion()
            {
                Person = "Bernd"
            };

            repo.Add(inf);
            repo.SaveAll();
        }
        public void EfContext_can_CRUD_Infektion()
        {
            var inf = new Infektion()
            {
                Person = $"Fred_{Guid.NewGuid()}", GebDatum = DateTime.Now.AddDays(-30000)
            };
            var newName = $"Wilma_{Guid.NewGuid()}";

            //CREATE
            using (var con = new EfContext())
            {
                con.Infektionen.Add(inf);
                Assert.AreEqual(1, con.SaveChanges());
            }

            //READ
            using (var con = new EfContext())
            {
                var loaded = con.Infektionen.Find(inf.Id);
                Assert.IsNotNull(loaded);
                Assert.AreEqual(inf.Person, loaded.Person);


                //Assert.AreEqual(inf.Modified, loaded.Modified);
                loaded.Modified.Should().BeCloseTo(inf.Modified);

                //UPDATE
                loaded.Person = newName;
                Assert.AreEqual(1, con.SaveChanges());
            }

            //verify UPDATE + DELETE
            using (var con = new EfContext())
            {
                var loaded = con.Infektionen.Find(inf.Id);
                Assert.AreEqual(newName, loaded.Person);

                con.Infektionen.Remove(loaded);
                Assert.AreEqual(1, con.SaveChanges());
            }

            //verfiy DELETE
            using (var con = new EfContext())
            {
                var loaded = con.Infektionen.Find(inf.Id);
                Assert.IsNull(loaded);
            }
        }
示例#6
0
        public void XmlRepo_can_add_Infektion_with_2_Virus()
        {
            var repo = new XmlRepository();
            var inf  = new Infektion()
            {
                Person = "Bernd"
            };

            inf.Viren.Add(new Virus()
            {
                Name = "v1"
            });
            inf.Viren.Add(new Virus()
            {
                Name = "v2"
            });

            repo.Add(inf);
            repo.SaveAll();
        }
示例#7
0
        public void XmlRepo_can_add_Infektion_and_Laender_asign_later()
        {
            var testFile = "myFile.xml";

            if (File.Exists(testFile))
            {
                File.Delete(testFile);
            }

            var inf1 = new Infektion()
            {
                Person = "Bernd"
            };
            var land = new Land()
            {
                Name = "Seuchenland"
            };

            land.Region.Add(new Region()
            {
                Name = "Todeszones"
            });

            {
                var repo = new XmlRepository(testFile);
                repo.Add(inf1);
                repo.Add(land);
                repo.SaveAll();
            }

            {
                var repo    = new XmlRepository(testFile);
                var iLoaded = repo.GetAll <Infektion>().FirstOrDefault();
                var lLoaded = repo.GetAll <Land>().FirstOrDefault();
                iLoaded.Wohnort = lLoaded.Region.FirstOrDefault();

                //repo.Update(iLoaded);
                repo.SaveAll();
            }
        }
        private void LoadDemo()
        {
            var v = new Virus()
            {
                Name = "Becks"
            };

            for (int i = 0; i < 10; i++)
            {
                var l = new Land()
                {
                    Name = $"l{i:00}"
                };
                var rl = new Region()
                {
                    Land = l
                };
                l.Region.Add(rl);

                var inf = new Infektion()
                {
                    Person = $"Fred #{i:000}"
                };
                inf.Wohnort = rl;
                rl.Infektionen.Add(inf);

                v.Infektionen.Add(inf);


                var ltvi = new LandTreeViewItem(l);
                var vtvi = new VirusTreeViewItem(v);
                ltvi.Viren.Add(vtvi);
                var itvi = new InfektionsTreeViewItem(inf);
                vtvi.Infektionen.Add(itvi);

                LandTreeViewItems.Add(ltvi);
            }
        }