public void ShouldGetEducationByUser()
        {
            var expected = _educations.Where(a => a.UserId == 1).ToList();
            _educationRepository = new Mock<IEducationRepository>();
            _educationRepository.Setup(a => a.Find(It.IsAny<Expression<Func<Education, bool>>>(), true))
                .Returns(expected);

            _educationLogic = new EducationLogic(_educationRepository.Object);

            var results = _educationLogic.GetByUser(1);

            Assert.AreEqual(2, results.Count);
        }
        public void ShouldAddEducation()
        {
            var dbResult = new Education
            {
                EducationId = 4,
                EducationType = new EducationType(),
                City = "Foo",
                State = "Bar",
                Country = "Baz",
                Course = "Fudge",
                UserId = 1,
                User = new User
                {
                    UserId = 1,
                    UserName = "******"
                }
            };
            _educationRepository = new Mock<IEducationRepository>();
            _educationRepository.Setup(a => a.Add(It.IsAny<Education>())).Returns(dbResult);

            _educationLogic = new EducationLogic(_educationRepository.Object);

            var result = _educationLogic.Add(new Common.Contracts.Education
            {
                EducationId = 4,
                EducationType = new Common.Contracts.EducationType(),
                City = "Foo",
                State = "Bar",
                Country = "Baz",
                Course = "Fudge",
                UserId = 1
            });

            Assert.IsNotNull(result);
        }
        public void ShouldThrowExceptionWhenGetEducationByUserFails()
        {
            _educationRepository = new Mock<IEducationRepository>();
            _educationRepository.Setup(a => a.Find(It.IsAny<Expression<Func<Education, bool>>>(), true))
                .Throws(new Exception());

            _educationLogic = new EducationLogic(_educationRepository.Object);
            Assert.Throws<BlogException>(() => _educationLogic.GetByUser(1));
        }
        public void ShouldThrowExceptionWhenDeleteEducationFails()
        {
            _educationRepository = new Mock<IEducationRepository>();
            _educationRepository.Setup(a => a.Delete(It.IsAny<Education>())).Throws(new Exception());

            _educationLogic = new EducationLogic(_educationRepository.Object);

            Assert.Throws<BlogException>(() => _educationLogic.Delete(1));
        }
        public void ShouldReturnFalseWhenDeleteEducationFoundNoRecord()
        {
            _educationRepository = new Mock<IEducationRepository>();
            _educationRepository.Setup(a => a.Find(It.IsAny<Expression<Func<Education, bool>>>(), false))
               .Returns(new List<Education>());

            _educationLogic = new EducationLogic(_educationRepository.Object);

            var result = _educationLogic.Delete(1);

            Assert.IsFalse(result);
        }
        public void ShouldReturnTrueOnDeleteEducation()
        {
            var dbResult = new List<Education> { new Education { EducationId = 1 } };
            _educationRepository = new Mock<IEducationRepository>();
            _educationRepository.Setup(a => a.Find(It.IsAny<Expression<Func<Education, bool>>>(), false))
               .Returns(dbResult);

            _educationLogic = new EducationLogic(_educationRepository.Object);

            var result = _educationLogic.Delete(1);

            Assert.IsTrue(result);
        }
        public void ShouldThrowExceptionWhenUpdateEducationFails()
        {
            _educationRepository = new Mock<IEducationRepository>();
            _educationRepository.Setup(a => a.Edit(It.IsAny<Education>())).Throws(new Exception());

            _educationLogic = new EducationLogic(_educationRepository.Object);

            Assert.Throws<BlogException>(() => _educationLogic.Update(new Common.Contracts.Education()));
        }