コード例 #1
0
        public void InsertAll_Test()
        {
            using var context = new ContextTest();

            var family1 = new Family
            {
                FamilyName = "Deligans"
            };

            context.Insert(family1);

            var listParent = new List <Parent>();

            var parent1 = new Parent
            {
                FamilyId  = family1.Id,
                FirstName = family1.FamilyName,
                LastName  = "Fabien",
            };

            var parent2 = new Parent
            {
                FamilyId  = family1.Id,
                FirstName = family1.FamilyName,
                LastName  = "Sandrine",
            };

            listParent.AddRange(new[] { parent1, parent2 });
            context.InsertAll(listParent);

            var listParentDatabase = context.QueryCollection <Parent>();

            Assert.AreEqual(2, listParentDatabase.Count());
        }
コード例 #2
0
        public void Update_Test()
        {
            using var context = new ContextTest();

            var family1 = new Family
            {
                FamilyName = "Deligans"
            };

            context.Insert(family1);

            var listParent = new List <Parent>();

            var parent1 = new Parent
            {
                FamilyId  = family1.Id,
                FirstName = family1.FamilyName,
                LastName  = "Fabien",
            };

            var parent2 = new Parent
            {
                FamilyId  = family1.Id,
                FirstName = family1.FamilyName,
                LastName  = "Sandrine",
            };

            listParent.AddRange(new[] { parent1, parent2 });
            context.InsertAll(listParent);

            var newFirstName = "Paulat";

            context.UpdateProperty(parent2, nameof(Parent.FirstName), newFirstName);

            var newParent2 = context.GetEntity <Parent>(parent2.Id);

            Assert.AreEqual(newFirstName, newParent2.FirstName);
        }
コード例 #3
0
        public void InsertOne_QueryCollection_GetEntity_Test()
        {
            using var context = new ContextTest();

            var allFamily = context.QueryCollection <Family>();

            Assert.AreEqual(0, allFamily.Count());

            var family1 = new Family
            {
                FamilyName = "Deligans"
            };

            context.Insert(family1);

            allFamily = context.QueryCollection <Family>();
            Assert.AreEqual(1, allFamily.Count());

            var getFamily = context.GetEntity <Family>(family1.Id);

            Assert.AreEqual(family1.Id, getFamily.Id);
            Assert.AreEqual(family1.FamilyName, getFamily.FamilyName);
        }