Esempio n. 1
0
        public void Execute_TestFixtureSetup()
        {
            //_workspaceId = CreateWorkspace.CreateWorkspaceAsync(_workspaceName, ConfigurationManager.AppSettings["TestWorkspaceTemplateName"], ServicesManager, _adminUsername, _adminPassword).Result;
            _workspaceId = 1017097;

            //Create instance of Test Helper & set up services manager
            TestHelper helper = new TestHelper();

            ServicesManager = helper.GetServicesManager();

            //Create client
            _client = ServicesManager.GetProxy <IRSAPIClient>(_adminUsername, _adminPassword);
        }
        public static async Task <int> CreateWorkspaceAsync(string workspaceName, string templateName, IServicesMgr svcMgr, string userName, string password)
        {
            Relativity.Client.IRSAPIClient client = svcMgr.GetProxy <Relativity.Client.IRSAPIClient>(userName, password);
            int num;

            try
            {
                client.APIOptions.WorkspaceID = -1;
                num = await Task.Run <int>((Func <int>)(() => CreateWorkspace.Create(client, workspaceName, templateName)));
            }
            finally
            {
                if (client != null)
                {
                    client.Dispose();
                }
            }
            return(num);
        }
        public void Execute_TestFixtureSetup()
        {
            try
            {
                //Start of test and setup
                Console.WriteLine("Test START.....");
                Console.WriteLine("Enter Test Fixture Setup.....");
                var helper = new TestHelper();

                //Setup for testing
                Console.WriteLine("Creating Test Helper Services Manager based on App.Config file settings.");
                _servicesManager = helper.GetServicesManager();
                Console.WriteLine("Services Manager Created.");

                Console.WriteLine("Creating workspace.....");
                if (!_debug)
                {
                    _workspaceId =
                        CreateWorkspace.CreateWorkspaceAsync(_workspaceName,
                                                             ConfigurationHelper.TEST_WORKSPACE_TEMPLATE_NAME, _servicesManager, ConfigurationHelper.ADMIN_USERNAME,
                                                             ConfigurationHelper.DEFAULT_PASSWORD).Result;
                    Console.WriteLine($"Workspace created [WorkspaceArtifactId= {_workspaceId}].....");
                }
                else
                {
                    //must point _workspaceId = valid workspace with application already installed
                    _workspaceId = _debugWorkspaceId;
                    Console.WriteLine($"Using existing workspace [WorkspaceArtifactId= {_workspaceId}].....");
                }


                Console.WriteLine("Creating RSAPI and Service Factory.....");
                try
                {
                    _eddsDbContext = helper.GetDBContext(-1);
                    _dbContext     = helper.GetDBContext(_workspaceId);

                    //create client
                    _client = _servicesManager.GetProxy <IRSAPIClient>(ConfigurationHelper.ADMIN_USERNAME, ConfigurationHelper.DEFAULT_PASSWORD);

                    LogStart("Application Import");
                    if (!_debug)
                    {
                        //Import Application
                        Relativity.Test.Helpers.Application.ApplicationHelpers.ImportApplication(_client, _workspaceId, true, _applicationFilePath, _applicationName);
                        LogEnd("Application Import");
                    }
                    else
                    {
                        Console.WriteLine($"Using existing application");
                    }



                    _client.APIOptions.WorkspaceID = _workspaceId;
                }
                catch (Exception ex)
                {
                    throw new Exception("Error encountered while creating new RSAPI Client and/or Service Proxy.", ex);
                }
                finally
                {
                    Console.WriteLine("Created RSAPI and Service Factory.....");
                }

                Console.WriteLine("Creating TestObject Helper.");
                //1 retry setting because I want to know if it fails quickly while debugging, may bump up for production
                _testObjectHelper = new TestObjectHelper(_servicesManager, _workspaceId, 1);
                Console.WriteLine("TestObject Helper Created.");
            }
            catch (Exception ex)
            {
                throw new Exception("Error encountered in Test Setup.", ex);
            }
            finally
            {
                Console.WriteLine("Exit Test Fixture Setup.....");
            }
        }