Exemple #1
0
        public async Task GetCompanyManagerByCompanyIdAsync_WithIncorectMenager_ShouldReturnArgumentNullException()
        {
            var context = SteuDbContextInMemoryFactory.InitializeContext();

            var company = new Company()
            {
                Id   = "asdasd",
                Name = "Test Ltd",
            };

            var user = new SteuUser()
            {
                Id      = "managerId",
                Manager = false,
            };

            company.Employees.Add(user);

            await context.AddAsync(company);

            await context.SaveChangesAsync();

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

            var service = new CompaniesService(repository);

            await Assert.ThrowsAsync <ArgumentNullException>(() => service.GetCompanyManagerByCompanyIdAsync("asdasd"));
        }
Exemple #2
0
        public async Task GetCompanyManagerByCompanyIdAsync_WithCorrectData_ShouldReturnCompany()
        {
            var context = SteuDbContextInMemoryFactory.InitializeContext();

            var company = new Company()
            {
                Id   = "asdasd",
                Name = "Test Ltd",
            };

            var user = new SteuUser()
            {
                Id      = "managerId",
                Manager = true,
            };

            company.Employees.Add(user);

            await context.AddAsync(company);

            await context.SaveChangesAsync();

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

            var service = new CompaniesService(repository);

            var actualResult = await service.GetCompanyManagerByCompanyIdAsync("asdasd");

            Assert.Equal("managerId", actualResult);
        }