/// <summary> /// Call this from the TearDown method in your NUnit initializer. Besides this call, there should be no other code in the method. /// </summary> public static void CleanUpStatics() { if (appInitializer != null) { appInitializer.CleanUpStatics(); } AppTools.CleanUp(); }
/// <summary> /// Call this from the SetUp method in your NUnit initializer. Besides this call, there should be no other code in the method. /// </summary> /// <param name="globalInitializer">The system's global initializer. Do not pass null.</param> /// <param name="appInitializer">The application initializer, which performs unit-testing-specific initialization and cleanup. If you have one of these you /// should name the class AppInitializer.</param> public static void InitStatics(SystemInitializer globalInitializer, SystemInitializer appInitializer = null) { AppTools.Init(globalInitializer, "Tests", false, useRelativeInstallationPath: true); try { if (AppTools.SecondaryInitFailed) { throw new ApplicationException( "An exception occurred during application initialization. Details should be available in an error email and the installation's error log."); } UnitTestingInitializationOps.appInitializer = appInitializer; if (appInitializer != null) { appInitializer.InitStatics(); } } catch { CleanUpStatics(); throw; } }
internal static void SendHealthCheckEmail(string appFullName) { var message = new EmailMessage(); message.ToAddresses.AddRange(EmailStatics.GetDeveloperEmailAddresses()); var body = new StringBuilder(); var tenGibibytes = 10 * Math.Pow(1024, 3); var freeSpaceIsLow = false; foreach (var driveInfo in DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Fixed)) { var bytesFree = driveInfo.TotalFreeSpace; freeSpaceIsLow = freeSpaceIsLow || bytesFree < tenGibibytes; body.AppendLine("{0} free on {1} drive.".FormatWith(FormattingMethods.GetFormattedBytes(bytesFree), driveInfo.Name)); } message.Subject = StringTools.ConcatenateWithDelimiter(" ", "Health check", freeSpaceIsLow ? "and WARNING" : "", "from " + appFullName); message.BodyHtml = body.ToString().GetTextAsEncodedHtml(); AppTools.SendEmailWithDefaultFromAddress(message); }