Example #1
0
        public void XmlRepo_can_CR_Infektion_AutoFix_FluentAss()
        {
            var fn  = "AutoFix.xml";
            var fix = new Fixture();

            fix.Behaviors.Add(new OmitOnRecursionBehavior());
            for (int i = 0; i < 10; i++)
            {
                var inf = fix.Create <Infektion>();

                using (var repo = new XmlRepository(fn))
                {
                    inf.Viren.ToList().ForEach(x => repo.Add(x));
                    repo.Add(inf.Wohnort.Land);
                    repo.Add(inf.Wohnort);
                    repo.Add(inf);
                    repo.SaveAll();
                }

                using (var con = new XmlRepository(fn))
                {
                    var loaded = con.GetById <Infektion>(inf.Id);
                    loaded.Should().BeEquivalentTo(inf, c =>
                    {
                        c.Using <DateTime>(ctx => ctx.Subject.Should().BeCloseTo(ctx.Expectation))
                        .WhenTypeIs <DateTime>();
                        c.IgnoringCyclicReferences();
                        return(c);
                    });
                }
            }
        }
    // Use this for initialization
    void Start()
    {
        // Load the world
        worldRepo = new XmlRepository <World>();
        worldData = worldRepo.GetById(new System.Guid("4e9b0641-b915-4259-b83e-c5ff96f86db9"));

        Debug.Log(worldData.Chunk.MinX() + "," + worldData.Chunk.MinY() + "," + worldData.Chunk.MaxX() + "," + worldData.Chunk.MaxY() + "," + worldData.Chunk.Width() + "," + worldData.Chunk.Height());
    }
        public void XmlRepoTests_Can_CRUD_Baum()
        {
            var baum = new Tannenbaum()
            {
                Height = 17
            };
            var newHeight = 452;

            {//INSERT
                var repo = new XmlRepository();
                repo.Add(baum);
                repo.Save();
            }


            {//check Read
                var repo = new XmlRepository();

                Assert.IsTrue(repo.GetAll <Tannenbaum>().Any(x => x.Height == baum.Height));
                var loaded = repo.GetById <Tannenbaum>(baum.Id);
                Assert.IsNotNull(loaded);
                Assert.AreEqual(baum.Height, loaded.Height);

                //UPDATE
                loaded.Height = 452;
                repo.Save();
            }

            {//check UPDATE + DELETE
                var repo   = new XmlRepository();
                var loaded = repo.GetById <Tannenbaum>(baum.Id);
                Assert.AreEqual(newHeight, loaded.Height);

                repo.Delete(loaded);
                repo.Save();
            }

            {//check DELETE
                var repo   = new XmlRepository();
                var loaded = repo.GetById <Tannenbaum>(baum.Id);
                Assert.IsNull(loaded);
            }
        }