コード例 #1
0
        public void CanCreate()
        {
            _testDatabase.RunAndRollback(dbContext =>
            {
                var skill = new Skill
                {
                    Name = "Snijden"
                };

                var createdSkill = new SkillRepository(dbContext).Create(skill);

                Assert.NotNull(createdSkill);
                Assert.True(createdSkill.Id > 0);
                Assert.Equal(skill.Name, createdSkill.Name);
            });
        }
コード例 #2
0
        public void CanGet()
        {
            _testDatabase.RunAndRollback(dbContext =>
            {
                var skill1 = new Skill
                {
                    Name = "Snijden"
                };

                var skill2 = new Skill
                {
                    Name = "Bakken"
                };

                dbContext.Skills.Add(skill1);
                dbContext.Skills.Add(skill2);
                dbContext.SaveChanges();

                var skill = new SkillRepository(dbContext).Get(skill2.Id);

                Assert.NotNull(skill);
                Assert.Equal(skill2.Id, skill.Id);
            });
        }
コード例 #3
0
        public void CanUpdate()
        {
            _testDatabase.RunAndRollback(dbContext =>
            {
                var updatedName = "Koken";

                var skill = new Skill
                {
                    Name = "Snijden"
                };

                dbContext.Skills.Add(skill);
                dbContext.SaveChanges();

                skill.Name = updatedName;
                var updatedSkill = new SkillRepository(dbContext).Update(skill);

                Assert.NotNull(updatedSkill);
                Assert.Equal(skill.Id, updatedSkill.Id);
                Assert.Equal(updatedName, updatedSkill.Name);
            });
        }