public ClassGroup Update(ClassGroup classGroup)
 {
     var updatedClassGroup = _dbContext.ClassGroups.Attach(classGroup);
     _dbContext.Entry(classGroup).State = EntityState.Modified;
     _dbContext.SaveChanges();
     return updatedClassGroup;
 }
        public void CanCreate()
        {
            var classGroupToCreateDto = new ClassGroupDto { Name = "Bakkers" };
            var createdClassGroup = new ClassGroup { Id = 1, Name = classGroupToCreateDto.Name };

            _classGroupRepository.Create(Arg.Any<ClassGroup>()).Returns(createdClassGroup);

            var createdClassGroupDto = _classGroupFacade.Create(classGroupToCreateDto);

            _classGroupRepository.Received().Create(Arg.Any<ClassGroup>());
            Assert.NotNull(createdClassGroupDto);
            Assert.Equal(createdClassGroup.Id, createdClassGroupDto.Id);
        }
        public void CanGet()
        {
            var classGroup = new ClassGroup { Id = 1, Name = "Bakkers" };

            _classGroupRepository.Get(classGroup.Id).Returns(classGroup);

            var foundClassGroup = _classGroupFacade.Get(classGroup.Id);

            _classGroupRepository.Received().Get(classGroup.Id);
            Assert.NotNull(foundClassGroup);
            Assert.Equal(classGroup.Id, foundClassGroup.Id);
            Assert.Equal(classGroup.Name, foundClassGroup.Name);
        }
        public void CanUpdate()
        {
            var updatedClassGroup = new ClassGroup { Id = 1, Name = "Bakkers" };
            var classGroupToUpdateDto = new ClassGroupDto { Id = updatedClassGroup.Id, Name = updatedClassGroup.Name };

            _classGroupRepository.Update(Arg.Any<ClassGroup>()).Returns(updatedClassGroup);

            var updatedClassGroupDto = _classGroupFacade.Update(classGroupToUpdateDto);

            _classGroupRepository.Received().Update(Arg.Any<ClassGroup>());
            Assert.NotNull(updatedClassGroupDto);
            Assert.Equal(updatedClassGroupDto.Id, updatedClassGroupDto.Id);
            Assert.Equal(updatedClassGroupDto.Name, updatedClassGroupDto.Name);
        }
        public void CanCreate()
        {
            _testDatabase.RunAndRollback(dbContext =>
            {
                var classGroup = new ClassGroup
                {
                    Name = "Slagers"
                };

                var createdClassGroup = new ClassGroupRepository(dbContext).Create(classGroup);

                Assert.NotNull(createdClassGroup);
                Assert.True(createdClassGroup.Id > 0);
                Assert.Equal(classGroup.Name, createdClassGroup.Name);
            });
        }
        public void CanGet()
        {
            _testDatabase.RunAndRollback(dbContext =>
            {
                var classGroup1 = new ClassGroup
                {
                    Name = "Slagers"
                };

                var classGroup2 = new ClassGroup
                {
                    Name = "Bakkers"
                };

                dbContext.ClassGroups.Add(classGroup1);
                dbContext.ClassGroups.Add(classGroup2);
                dbContext.SaveChanges();

                var classGroup = new ClassGroupRepository(dbContext).Get(classGroup2.Id);

                Assert.NotNull(classGroup);
                Assert.Equal(classGroup2.Id, classGroup.Id);
            });
        }
 public ClassGroup Create(ClassGroup classGroup)
 {
     var createdClassGroup = _dbContext.ClassGroups.Add(classGroup);
     _dbContext.SaveChanges();
     return createdClassGroup;
 }
        public void CanUpdate()
        {
            _testDatabase.RunAndRollback(dbContext =>
            {
                var updatedName = "Koks";

                var classGroup = new ClassGroup
                {
                    Name = "Slagers"
                };

                dbContext.ClassGroups.Add(classGroup);
                dbContext.SaveChanges();

                classGroup.Name = updatedName;
                var updatedClassGroup = new ClassGroupRepository(dbContext).Update(classGroup);

                Assert.NotNull(updatedClassGroup);
                Assert.Equal(classGroup.Id, updatedClassGroup.Id);
                Assert.Equal(updatedName, updatedClassGroup.Name);
            });
        }
        public void CanDelete()
        {
            _testDatabase.RunAndRollback(dbContext =>
            {
                var classGroup1 = new ClassGroup
                {
                    Name = "Slagers"
                };

                var classGroup2 = new ClassGroup
                {
                    Name = "Bakkers"
                };

                dbContext.ClassGroups.Add(classGroup1);
                dbContext.ClassGroups.Add(classGroup2);
                dbContext.SaveChanges();

                new ClassGroupRepository(dbContext).Delete(classGroup1.Id);

                Assert.Equal(1, dbContext.ClassGroups.Count());
                Assert.Equal(classGroup2.Id, dbContext.ClassGroups.First().Id);
            });
        }