public void GetEducation_Pass()
        {
            using (ApplicationDbContext context = new ApplicationDbContext(Options))
            {
                EducationService educationService = new EducationService(context);
                UserService      userService      = new UserService(context);

                User user = new User
                {
                    FirstName = "Kyle",
                    LastName  = "Burgi"
                };

                userService.AddUser(user);

                Education edu = new Education
                {
                    CollegeName  = "Eastern Washington University",
                    FieldOfStudy = "Computer Science",
                    UserId       = user.Id
                };

                educationService.AddEducation(edu);
            }

            using (ApplicationDbContext context = new ApplicationDbContext(Options))
            {
                EducationService educationService = new EducationService(context);
                Education        fetchedEducation = educationService.GetEducation(1);

                Assert.AreEqual("Eastern Washington University", fetchedEducation.CollegeName);
                Assert.AreEqual(1, fetchedEducation.UserId);
            }
        }
Пример #2
0
 public IHttpActionResult GetEducation(long educationId)
 {
     try
     {
         return(Ok(_educationService.GetEducation(educationId)));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
Пример #3
0
        public void GetEducationShouldReturnAnEducationById()
        {
            var options   = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("Database_For_CreatingEducations").Options;
            var dbContext = new ApplicationDbContext(options);
            var service   = new EducationService(dbContext);

            var education = new Education
            {
                Title = "Test"
            };

            dbContext.Educations.Add(education);
            dbContext.SaveChanges();

            var returnedEducation = service.GetEducation(1);

            Assert.Equal(education.Title, returnedEducation.Title);
        }