public async Task AddAsyncCompanyShouldReturnCorrectDataFromDbContext( string name, string description, string logoImg, string officialSite, string userId, int categoryId) { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var repository = new EfDeletableEntityRepository <Company>(dbContext); var service = new CompaniesService(repository); int companyId = await service.AddAsync(name, description, logoImg, officialSite, userId, categoryId); var result = service.GetById(companyId); Assert.Equal(1, result.Id); Assert.Equal(name, result.Name); Assert.Equal(description, result.Description); Assert.Equal(logoImg, result.LogoImage); Assert.Equal(officialSite, result.OfficialSite); Assert.Equal(userId, result.UserId); Assert.Equal(categoryId, result.CategoryId); }
public async Task AddAsync_AddsEntity() { //Assert //Act await testedService.AddAsync(newEntity); //Assert Mock.Verify(c => c.Add(newEntity), Times.Once()); Mock.Verify(c => c.SaveChangesAsync(It.IsAny <CancellationToken>()), Times.Once()); }