Ejemplo n.º 1
0
        public async Task <int> EditByIdAsyncShouldReturnTrueWithCorrectInputUsingDbContext()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "CompanyTest123").Options;
            var dbContext = new ApplicationDbContext(options);

            dbContext.Companies.Add(new Company
            {
                Id           = 1,
                Name         = "C1",
                Description  = "desc",
                LogoImage    = "image",
                OfficialSite = "officialSite",
                CategoryId   = 1
            });
            await dbContext.SaveChangesAsync();

            var repository    = new EfDeletableEntityRepository <Company>(dbContext);
            var tagRepository = new EfDeletableEntityRepository <Tag>(dbContext);
            var service       = new CompaniesService(repository, tagRepository);
            var result        = await service.EditById(1, "C11", "desc", "image", "officialSite", 1);

            Assert.Equal(1, result);
            return(result);
        }