示例#1
0
        public async Task EditShouldEditEmployer()
        {
            string description = "Test Description";
            string city        = "City";
            string country     = "Country";

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

            dbContext.Add(new Employer
            {
                Description = description,
                City        = city,
                Country     = country,
            });
            await dbContext.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <Employer>(dbContext);
            var service    = new EmployerService(repository, null);

            var expected = new Employer
            {
                Description = description + "edit",
                City        = city + "edit",
                Country     = country + "edit",
            };

            await service.EditAsync(
                1,
                city + "edit",
                country + "edit",
                description + "edit",
                null);

            var result = service.GetById(1);

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