public static void OneTimeSetUp() { // do this once-and-for-all when unit testing // Logger.EnableConsoleLogging = true; Logger.AlwaysIncrementLogNumber = true; ArasPermissionGrant.Disable = true; _connectionCount++; if (_connectionCount > 1) { if (Innovator == null) { throw new ArasException("ArasTestBase Setup failed."); } return; } var loginInfo = LoginInfo.Load(); if (loginInfo == null) { throw new ArasException("No user logged in. Cannot run tests against Aras."); } var slnDir = TestContext.CurrentContext.TestDirectory; while (slnDir != null && !Directory.EnumerateFiles(slnDir, "*.sln").Any()) { slnDir = Directory.GetParent(slnDir).FullName; } if (slnDir == null) { throw new ArasException( $"Failed to find top/solution directory in parents of {TestContext.CurrentContext.TestDirectory}"); } Console.WriteLine(slnDir); var developmentDb = GetDevelopmentDb(slnDir); Connection = IomFactory.CreateHttpServerConnection( developmentDb.Url, developmentDb.DbName, loginInfo.Username, loginInfo.Password); Connection.Timeout = 15000; // need time for AppPool recycle on new DLLs Connection.Compression = CompressionType.deflate; LoginItem = Connection.Login(); if (LoginItem.isError()) { throw new ArasException("Aras login failed: " + LoginItem.getErrorString()); } Innovator = LoginItem.getInnovator(); LogFolder = TestContext.CurrentContext.WorkDirectory; ArasExtensions.Innovator = Innovator; ArasExtensions.LogRootFolder = LogFolder; }
public static void ClassInitialize(TestContext ctx) { _connectionCount++; if (_connectionCount > 1) { if (Innovator == null) { throw new ArasException("ArasTestBase Setup failed."); } return; } var loginInfo = LoginInfo.Load(); if (loginInfo == null) { throw new ArasException("No user logged in. Cannot run tests against Aras."); } var slnDir = ctx.TestRunDirectory; while (slnDir != null && !Directory.EnumerateFiles(slnDir, "*.sln").Any()) { slnDir = Directory.GetParent(slnDir).FullName; } if (slnDir == null) { throw new ArasException( $"Failed to find top/solution directory in parents of {ctx.TestRunDirectory}"); } var developmentDb = GetDevelopmentDb(slnDir); Connection = IomFactory.CreateHttpServerConnection( developmentDb.Url, developmentDb.DbName, loginInfo.Username, loginInfo.Password); Connection.Timeout = 15000; // need time for AppPool recycle on new DLLs Connection.Compression = CompressionType.none; LoginItem = Connection.Login(); if (LoginItem.isError()) { throw new ArasException("Aras login failed: " + LoginItem.getErrorString()); } Innovator = LoginItem.getInnovator(); LogFolder = ctx.TestDir; // dont use name, shared by many tests ArasExtensions.Innovator = Innovator; ArasExtensions.LogRootFolder = LogFolder; }