コード例 #1
0
        public async Task EditShouldEditJobPost()
        {
            string title       = "Test 1";
            string description = "Test Description";
            string city        = "City";
            string country     = "Country";

            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "JobEditDb").Options;
            var dbContext = new ApplicationDbContext(options);

            var repository    = new EfDeletableEntityRepository <JobPost>(dbContext);
            var tagRepository = new Mock <ITagService>();
            var service       = new JobPostsService(repository, tagRepository.Object);

            var id = await service.CreateAsync(title, description, city, country, 1, string.Empty);

            var expected = new JobPost
            {
                Title       = title + "edit",
                Description = description + "edit",
                City        = city + "edit",
                Country     = country + "edit",
                EmployerId  = 1,
            };

            await service.EditAsync(
                id,
                title + "edit",
                description + "edit",
                city + "edit",
                country + "edit",
                string.Empty);

            var result = service.GetJobPost(id);

            Assert.True(
                expected.Title == result.Title &&
                expected.Description == result.Description &&
                expected.City == result.City &&
                expected.Country == result.Country &&
                expected.EmployerId == result.EmployerId);
        }