Пример #1
0
        public async Task SetUp()
        {
            _mapper = TestMapperConfiguration.Config.CreateMapper();
            await InitOnce();

            await _apiClient.AsGryffindorAdminAsync(_httpClient);
        }
Пример #2
0
        public async Task SetUp()
        {
            await InitOnce();

            // start each test as Gryffindor user
            await _apiClient.AsGryffindorAdminAsync(_httpClient);
        }
Пример #3
0
        public async Task SetUp()
        {
            await InitOnce();

            // start each test as Gryffindor user
            await _apiClient.AsGryffindorAdminAsync(_httpClient);

            if (_operatorWorkplaceCredentials == null)
            {
                await CreateDepartmentCredentialsAsync();
            }
        }
    private async Task SeedTestInspections(IApiClient apiClient)
    {
      {
        await apiClient.AsGryffindorAdminAsync(_httpClient);

        var newEmployee = new EmployeeDto
        {
          FirstName = "John",
          LastName = "Doe",
          Patronymic = "Alan",
          PositionId = _gryffindorHouse.Position_Default.Id,
          DepartmentId = _gryffindorHouse.Department_1_1.Department.Id,
          BranchOfficeId = _gryffindorHouse.BranchOffice_One.Id
        };
        var employeeId = await apiClient.PostEmployeeAsync(newEmployee);

        var gryInspection = new InspectionDto
        {
          Id = Guid.NewGuid().ToString(),
          MethodSetId = "Method_Set_Id",
          StartTime = DateTime.Now - TimeSpan.FromMinutes(700),
          FinishTime = DateTime.Now - TimeSpan.FromMinutes(700),
          InspectionPlace = InspectionPlace.OnWorkplace,
          InspectionType = InspectionType.PreShift,
          EmployeeId = employeeId.ToString(),
          MachineName = "HOST002-gry",
          MethodSetVersion = "Version 16"
        };
        _gryffindorInspectionId = await PostManyInspections(apiClient, gryInspection);
      }
      {
        await apiClient.AsSlytherinAdminAsync(_httpClient);

        var newEmployee = new EmployeeDto
        {
          FirstName = "John",
          LastName = "Doe",
          Patronymic = "Alan",
          PositionId = _slytherinHouse.Position_Default.Id,
          DepartmentId = _slytherinHouse.Department_1_1.Department.Id,
          BranchOfficeId = _slytherinHouse.BranchOffice_One.Id
        };
        var employeeId = await apiClient.PostEmployeeAsync(newEmployee);

        var slyInspection = new InspectionDto
        {
          Id = Guid.NewGuid().ToString(),
          MethodSetId = "Method_Set_Id",
          StartTime = DateTime.Now - TimeSpan.FromMinutes(700),
          FinishTime = DateTime.Now - TimeSpan.FromMinutes(700),
          InspectionPlace = InspectionPlace.OnWorkplace,
          InspectionType = InspectionType.PreShift,
          EmployeeId = employeeId.ToString(),
          MachineName = "HOST002-sly",
          MethodSetVersion = "Version 16"
        };
        _slytherinInspectionId = await PostManyInspections(apiClient, slyInspection);
      }
    }
Пример #5
0
        private async Task InitOnce()
        {
            if (_app != null)
            {
                return;
            }

            LogHelper.ConfigureConsoleLogger();

            _app = new DefaultWebApplicationFactory();

            var options = new WebApplicationFactoryClientOptions()
            {
                AllowAutoRedirect = false
            };

            _httpClient = _app.CreateClient(options);

            _unauthorizedHttpClient = _app.CreateClient(options);
            _unauthorizedHttpClient.DefaultRequestHeaders.Add("accept", "application/json");

            _apiClient = new ApiClient(_httpClient, _app.GetLogger <ApiClient>());
            await _apiClient.AsSiteAdminAsync(_httpClient);

            _siteAdminUser = await _apiClient.GetCurrentUserAsync();

            _siteRoles = (await _apiClient.GetRolesAsync()).ToList();

            {
                var gryffindorTenant = await TestTenants.CreateTenantWithRolesAndUsers(
                    _apiClient, _httpClient, TestTenants.GryffindorHouse);

                _gryffindorAdminUser = gryffindorTenant.AdminUser;

                await _apiClient.AsGryffindorAdminAsync(_httpClient);

                _gryffindorRoles = (await _apiClient.GetRolesAsync()).ToList();

                _gryffindorAdminRoleId = gryffindorTenant.TenantAdminRoleId.ToString();
            }

            await _apiClient.AsSiteAdminAsync(_httpClient);

            {
                var slytherinTenant = await TestTenants.CreateTenantWithRolesAndUsers(
                    _apiClient, _httpClient, TestTenants.SlytherinHouse);

                _slytherinAdminUser = slytherinTenant.AdminUser;

                await _apiClient.AsSlytherinAdminAsync(_httpClient);

                _slytherinRoles = (await _apiClient.GetRolesAsync()).ToList();

                _slytherinAdminRoleId = slytherinTenant.TenantAdminRoleId.ToString();
            }
        }
Пример #6
0
        public async Task SetUp()
        {
            _mapper = TestMapperConfiguration.Config.CreateMapper();

            await InitOnce();

            _apiClient = new ApiClient(_httpClient, _app.GetLogger <ApiClient>());

            // the tests start with a Gryffindor user
            await _apiClient.AsGryffindorAdminAsync(_httpClient);
        }
Пример #7
0
        private async Task InitOnce()
        {
            if (_app != null)
            {
                return;
            }

            LogHelper.ConfigureConsoleLogger();

            _app = new DefaultWebApplicationFactory();

            var options = new WebApplicationFactoryClientOptions {
                AllowAutoRedirect = false
            };

            _httpClient = _app.CreateClient(options);

            var apiClient = new ApiClient(_httpClient, _app.GetLogger <ApiClient>());

            apiClient.TraceResponseOnException = true;

            _apiClient = apiClient;

            // site admin creates 2 tenants
            await _apiClient.AsSiteAdminAsync(_httpClient);

            _gryffindorHouse = await TestTenants.CreateTenantWithRolesAndUsers(_apiClient, _httpClient, TestTenants.GryffindorHouse);

            await _apiClient.AsSiteAdminAsync(_httpClient);

            _slytherinHouse = await TestTenants.CreateTenantWithRolesAndUsers(_apiClient, _httpClient, TestTenants.SlytherinHouse);

            // Slytherin House admin creates branch office and departments
            await _apiClient.AsSlytherinAdminAsync(_httpClient);

            TestBranchOffice.SeedDefaultBranchOffice(_apiClient, _httpClient, _slytherinHouse).Wait();
            TestDepartment.SeedDefaultDepartments(_apiClient, _slytherinHouse).Wait();
            TestPosition.SeedDefaultPosition(_apiClient, _slytherinHouse).Wait();
            TestEmployees.SeedDefaultEmployees(_apiClient, _slytherinHouse).Wait();

            // Gryffindor House admin creates branch office and departments
            await _apiClient.AsGryffindorAdminAsync(_httpClient);

            TestBranchOffice.SeedDefaultBranchOffice(_apiClient, _httpClient, _gryffindorHouse).Wait();
            TestDepartment.SeedDefaultDepartments(_apiClient, _gryffindorHouse).Wait();
            TestPosition.SeedDefaultPosition(_apiClient, _gryffindorHouse).Wait();
            TestEmployees.SeedDefaultEmployees(_apiClient, _gryffindorHouse).Wait();

            _workDepartmentId = _gryffindorHouse.Department_1_2.Department.Id;
        }
Пример #8
0
        public async Task GetAllDepartments_ShouldSucceed()//
        {
            // Given
            // user authenticated in tenant #1 (Gryffindor House)
            // created 2 departments just created in Gryffindor House
            // and 1 department just created in Slytherin House
            var departmentDto1 = new DepartmentDto
            {
                Name           = "Department #1001",
                BranchOfficeId = _gryffindorHouse.BranchOffice_One.Id
            };
            var createFirstDepartmentid = await _apiClient.PostDepartmentAsync(departmentDto1);

            Console.WriteLine($"#1001 => {createFirstDepartmentid}");

            var departmentDto = new DepartmentDto
            {
                Name           = "Department #1002",
                BranchOfficeId = _gryffindorHouse.BranchOffice_One.Id
            };

            var createSecondDepartmentId = await _apiClient.PostDepartmentAsync(departmentDto);

            Console.WriteLine($"#1002 => {createSecondDepartmentId}");

            await _apiClient.AsSlytherinAdminAsync(_httpClient);

            var slytherinDepartmentDto = new DepartmentDto
            {
                Name           = "Slytherin Department #1002",
                BranchOfficeId = _slytherinHouse.BranchOffice_One.Id
            };
            var createSlytherinDepartmentId = await _apiClient.PostDepartmentAsync(slytherinDepartmentDto);

            Console.WriteLine($" slytherin => {createSlytherinDepartmentId}");

            // When
            // Gryffindor user requests all departments
            await _apiClient.AsGryffindorAdminAsync(_httpClient);

            var availableGryffindorDepartments = await _apiClient.GetDepartmentsAsync();

            // Then
            // the request should succeed and return more than 1 departments
            Assert.That(availableGryffindorDepartments.Count(), Is.GreaterThanOrEqualTo(2));
        }
Пример #9
0
        private async Task InitOnce()
        {
            if (_app != null)
            {
                return;
            }

            LogHelper.ConfigureConsoleLogger();

            _app = new DefaultWebApplicationFactory();

            var options = new WebApplicationFactoryClientOptions()
            {
                AllowAutoRedirect = false
            };

            _httpClient = _app.CreateClient(options);

            _apiClient = new ApiClient(_httpClient, _app.GetLogger <ApiClient>());
            // admin creates Gryffindor tenant and initializes default branch office
            await _apiClient.AsSiteAdminAsync(_httpClient);

            _siteAdminUser = await _apiClient.GetCurrentUserAsync();

            _gryffindorHouse = await TestTenants.CreateTenantWithRolesAndUsers(_apiClient, _httpClient, TestTenants.GryffindorHouse);

            await _apiClient.AsGryffindorAdminAsync(_httpClient);

            await TestBranchOffice.SeedDefaultBranchOffice(_apiClient, _httpClient, _gryffindorHouse);

            // admin creates Slytherin tenant and initializes default branch office
            await _apiClient.AsSiteAdminAsync(_httpClient);

            _slytherinHouse = await TestTenants.CreateTenantWithRolesAndUsers(_apiClient, _httpClient, TestTenants.SlytherinHouse);

            await _apiClient.AsSlytherinAdminAsync(_httpClient);

            await TestBranchOffice.SeedDefaultBranchOffice(_apiClient, _httpClient, _slytherinHouse);
        }
        public async Task SetUp()
        {
            await InitOnce();

            await _apiClient.AsGryffindorAdminAsync(_httpClient);
        }
 public async Task SetUp()
 {
   LogHelper.ConfigureConsoleLogger();
   await InitOnce();
   await _apiClient.AsGryffindorAdminAsync(_httpClient);
 }