Пример #1
0
        public async Task DeleteUserCompanyByCompanyIdAsyncTest_WithInCorrectData_ShouldReturnArgumentNullException()
        {
            var context = SteuDbContextInMemoryFactory.InitializeContext();
            await context.Companies.AddAsync(new Company()
            {
                Id   = "asdasd",
                Name = "Test Ltd",
            });

            await context.SaveChangesAsync();

            MapperInitializer.InitializeMapper();
            var repository = new EfDeletableEntityRepository <Company>(context);

            var service = new CompaniesService(repository);

            await Assert.ThrowsAsync <ArgumentNullException>(() => service.DeleteUserCompanyByCompanyIdAsync("Test"));
        }
Пример #2
0
        public async Task DeleteUserCompanyByCompanyIdAsyncTest_WithCorrectData_ShouldReturnEmptyList()
        {
            var context = SteuDbContextInMemoryFactory.InitializeContext();
            await context.Companies.AddAsync(new Company()
            {
                Id   = "asdasd",
                Name = "Test Ltd",
            });

            await context.SaveChangesAsync();

            MapperInitializer.InitializeMapper();
            var repository = new EfDeletableEntityRepository <Company>(context);

            var service = new CompaniesService(repository);

            await service.DeleteUserCompanyByCompanyIdAsync("asdasd");

            var companies = await repository.All().ToListAsync();

            Assert.Empty(companies);
        }