AutomationToolsCore 2.0.5

dotnet add package AutomationToolsCore --version 2.0.5
NuGet\Install-Package AutomationToolsCore -Version 2.0.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AutomationToolsCore" Version="2.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AutomationToolsCore --version 2.0.5
#r "nuget: AutomationToolsCore, 2.0.5"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AutomationToolsCore as a Cake Addin
#addin nuget:?package=AutomationToolsCore&version=2.0.5

// Install AutomationToolsCore as a Cake Tool
#tool nuget:?package=AutomationToolsCore&version=2.0.5

Alaska ITS QE Automation Tools

The information in this document is to provide an overview of the available functionality within this package. It was designed for Crew Tools API and UI Automation but can easily be applied to any automation portfolio.

What's New?

  1. Here you will find the latest updates.

Key Features

Below are the essential classes of this library, commonly used functions from those classes, and a brief explanation of their use cases. Please use these functions when ever possbile. It will save time in test writing.

Shared Tools

  • Key Features

    Automation Logger

    1. AddToLog()

      1. Add a message to the log. This can be any information that needs to be logged. An enum can be passed to make it a warning message or error message, though the two below functions are preferred.

         // Log test data
         AutomationLogger.AddToLog($"Testing using: {randomEvent}");
        

    </br>

    1. LogWarning()

      1. Log a warning, this should not be used for validation logging.

         AutomationLogger.LogWarning($"Class with Trip Identifier: {classInfo.TripIdentifier} may have been reset, no equivalent found in DB Scheduled class list");
        

    </br>

    1. LogError()

      1. Log an error. This should be used for any condition that would indicate a test/feature failure.

         AutomationLogger.LogError($"{eventDB} not found in DB");
        

    </br>

    1. GetPST()

      1. Returns the current time in PST timezone, most applications need PST time, all logs are in PST time.

         var currentDate = AutomationLogger.GetPST().ToString("yyyy-MM");
        

    </br>

    1. SetBaseURL()

      1. This is used in the construction of an API controller in order to set the base URL of an API in the logger.

         public CreamController(APIConfigs apiConfigs) : base(apiConfigs)
         {
         	AutomationLogger.SetBaseURL(apiConfigs.BaseURL);
         	AutomationLogger.AddToLog("Cream Controller created");
         }
        

    </br>

    1. SetDBType()

      1. This is used in the construction of a DB controller in order to set the type of database that's being used.

         public CreamDB(string connectionString)
         {
         	AutomationLogger.AddToLog("Opening Cream DB connection");
         	AutomationLogger.SetDBType("MS-SQL");
         	ConnectionString = connectionString;
         	ModelGenerator = new SQLModelGenerator();
         	QueryFileName = "DatabaseQueryMapping";
         }
        

    </br>

    1. ConfigureLogger()

      1. This is a required setup function. Pass the name of the Application, the testing type (BVT, Smoke, etc.) and the environment (QA, Test, etc.).

         public void Setup()
         {
         	RandomizerTool = new AutomationRandomizerTools();
         	CreamHelper = new CreamHelper();
        
         	AutomationLogger.ConfigureLogger(
         		appName: "Cream",
         		testType: TestType.Functional,
         		environment: TestContext.Parameters.Get("Env") ?? string.Empty);
         }
        

    </br>

    1. ReconfigureLogger()

      1. This is used when comparing two different API environments. Example: (QA and Production) This is for logging clarity only.

         // Reconfigure the logger for Production
         AutomationLogger.ReconfigureLogger();
        
         // Reconfigure the logger for QA
         AutomationLogger.ReconfigureLogger("QA");
        

    </br>

    1. LogTestResult()

      1. This is a required test completion function. Pass the name of the test function, true or false, and the Automation Core Driver object reference where appropriate (UI testing only).

         finally
         {
         	// Log test result
         	AutomationLogger.LogTestResult(System.Reflection.MethodBase.GetCurrentMethod().Name, testPassed);
         	// Assert test passed
         	Assert.IsTrue(testPassed);
         }
        

    </br>

    1. TestConditionsNotMet()

      1. This can be used to show that conditions for a test are not met. This should be used sparingly. An option message can be added to explain.

         AutomationLogger.TestConditionsNotMet($"No data recovered from GetCrewInfo endpoint for FA with Id: {randomFA.GetValueByAttributeName("crewId")}");
        

    </br>

    1. NoErrorsPresent()

      1. This is an essential function. API helper functions should return a boolean using this function.

         return AutomationLogger.NoErrorsPresent();
        

    </br>

    1. CatchException()

      1. This is an essential function. Will log any exception including an Inner Exception if one exists. Use with all test executions.

         catch (Exception ex)
         {
         	// Catch any unhandled exceptions that may occur
         	AutomationLogger.CatchException(System.Reflection.MethodBase.GetCurrentMethod()!.Name, ex);
         }
        

    </br>

    1. LogDBQuery()

      1. Log a database query. This facilites manual verification.

         var sqlQuery = AutomationSQLTools.GetStoredQuery(
         	filename: QueryFileName!,
         	queryName: System.Reflection.MethodBase.GetCurrentMethod()!.Name);
        
         AutomationLogger.LogDBQuery(sqlQuery.Replace("@evtdtl_id", evtdtl_id));
        

    </br>

    1. LogValueMismatch()

      1. This is an essential function. When two objects are not equal, pass the objects(two strings, two ints, a string and an int, etc.) and their sources (DB and API, QA and Production, etc.) and the column name to this for logging. This is a boiler plate function and will work with any object type.

         if (!currentEvent.Reason!.StringsMatch(eventDB.Evt_code!))
         {
         	AutomationLogger.LogValueMismatch(
         		object1: eventDB.Evt_code!,
         		object2: currentEvent.Reason,
         		source1: "Cream DB",
         		source2: "Cream API",
         		fieldName: "Event Code");
         }
        

    </br>

    Randomizer Tool

    The Randomizer Tool is only psuedo random and not to be used for any kind of security or cryptograpic purposes.

    1. GetRandomDate()

      1. Gets a random date between the base date and today. Default base date is 1/1/2000. Base year, month, and day are optional variables. DateTime object will be in the PST timezone.

         // Get Random Date to test
         var dateToTest = RandomizerTool.GetRandomDate().ToString("M-d-yyyy");
        

      </br>

    2. GetRandomFutureDate()

      1. Gets a random date in the future. Optional variables can be supplied to adjust the range. The default range is 5 years. The default base date is current year + 1 on January 1st.

         var startDate = AutomationRandomizerTools.GetRandomFutureDate(2, AutomationLogger.GetPST().AddYears(-1).Year).ToString("MM/dd/yyyy");
        

      </br>

    3. GetRandomDateInRange()

      1. Returns a random date between two DateTime objects, two strings, or one of each. If a non-datetime string is provided, returns DateTime.MinValue.

         // get current PST time
         var now = AutomationLogger.GetPST();
         // get random start date up to 6 weeks prior
         var startDate = RandomizerTool!.GetRandomDateInRange(now.AddDays(-42), now);
         // get random end date up to 17 weeks later
         var endDate = RandomizerTool.GetRandomDateInRange(now, now.AddDays(7 * 17));
        

      </br>

    4. GetRandomString()

      1. Creates a pseudo random string. Default length is 10 characters and numbers are inlcuded by default. Can include upper and lower case letters. This SHOULD NOT be used for any kind of security or crptography.

         // create random meta data
         var metaData = new Dictionary<string, string>
         {
         	{ $"{RandomizerTool.GetRandomString(10, false)}", $"{RandomizerTool.GetRandomString(16, false)}" },
         	{ $"{RandomizerTool.GetRandomString(10, false)}", $"{RandomizerTool.GetRandomString(16, false)}" }
         };
        

      </br>

    5. GetRandomTime() </br>

    6. GetRandomObjectFromCollection()

      1. This will select a random object from the supplied collection. Works with Lists and Arrays.

      2. A string array can also be provided containing field names that must not be null when selecting a random entry.

       // Fetch a random entry from the list
       var randomEvent = RandomizerTool!.GetRandomObjectFromCollection(events!);
      

      </br>

    7. GetRandomDoubleAsString() </br>

  1. Extensions

    1. IsNullOrEmpty()

      1. This function will return true if a string is empty, a collection is empty, or any object is null.
       // Validate file exists in DB
       if (!documentData.IsNullOrEmpty())
      
    2. DateFormat()

      1. This function takes in a string and will return a date string in the supplied format if the string is a valid DateTime string, otherwise, it returns an empty string or the original string.
       // past month will only fetch data from DB and current will fetch from FTSA Prod api as well as Firefly DB
       if (Convert.ToDateTime(startDate.DateFormat("yyyy-MM")) >= Convert.ToDateTime(currentDate))
      
    3. DatesMatch()

      1. This function has four variants:

        1. Compare two strings

        2. Compare a DateTime object and a string

        3. Compare a string and a DateTime object

        4. Compare two DateTime objects

      2. It will return true if both dates match, time is not checked by default but can be if desired.

       if (!auth.Auth_last_modified_datetime!.DatesMatch(currentAPI.Auth_last_modified_datetime!))
       {
       	AutomationLogger.LogValueMismatch(
       		object1: auth.Auth_last_modified_datetime!,
       		object2: currentAPI.Auth_last_modified_datetime,
       		source1: "Cream DB",
       		source2: "Cream API",
       		fieldName: "Auth_last_modified_datetime");
       }
      
    4. StringsMatch()

      1. This function will return true if two strings match. Case is not considered by default but can be if desired.
       if (!auth.Auth_last_modified_by!.StringsMatch(currentAPI.Auth_last_modified_by!))
       {
       	AutomationLogger.LogValueMismatch(
       		object1: auth.Auth_last_modified_by!,
       		object2: currentAPI.Auth_last_modified_by,
       		source1: "Cream DB",
       		source2: "Cream API",
       		fieldName: "Auth_last_modified_by");
       }
      
    5. StringifyDictionary()

      1. This function converts a Dictionary of type <string, string> into a JSON friendly string.
       // convert the supplied meta data into a JSON friendly string
       var keyValues = Extensions.StringifyDictionary(metaData);
      
    6. CombineDictionaries()

      1. This combines two Dictionaries into one. This has only been tested with <string, string> dictionaries.
       // add to the current metadata
       Extensions.CombineDictionaries(requestSearch.DocumentMetadata, entries);
      
    7. DictionariesMatch()

      1. This returns true if two dictionaries match completely. This has only been tested with <string, string> dictionaries.
    8. CompareBools()

      1. Accepts any combination of booleans, ints, and string and returns true if they match.
       if (!item.IsProtected.CompareBools(currentDocument.Is_protected))
       {
       	AutomationLogger.LogValueMismatch(
       		object1: item.IsProtected,
       		object2: currentDocument.Is_protected,
       		source1: "Crew Files API",
       		source2: "Crew Files DB",
       		fieldName: "IsProtected");
       }
      
  2. Encryption

  3. SQL Model Generator

    1. The parameters are the model type and the SQL data reader.

    2. Reader options:

      1. SQLDataReader

      2. DB2DataReader

      3. OracleDataReader

    3. Example usage:

     connection.Open();
     var reader = command.ExecuteReader();
    
     while (reader.Read())
     {
     	getScheduledClassesDbData.Add(ModelGenerator.GenerateModel<ScheduledClassesDetailsDB>(reader));
     }
    
     reader.Close();
    
    1. This removes the need to set each variable within a model.

    2. Example of code being replaced:

     connection.Open();
     var reader = command.ExecuteReader();
    
     while (reader.Read())
     {
     	getScheduledClassesDbData.Add(new ScheduledClassesDetailsDB()
     	{
     		TripIdentifier = reader["TripIdentifier"].ToString().Trim(),
     		Code = reader["training_code"].ToString().Trim(),
     		StartTime = reader["training_default_starttime"].ToString().Trim(),
     		EndTime = reader["training_default_endtime"].ToString().Trim(),
     		StartDate = reader["training_startDate"].ToString().Trim(),
     		EndDate = reader["training_endDate"].ToString().Trim(),
     		Size = reader["training_classsize"].ToString().Trim(),
     		Base = reader["training_base"].ToString().Trim(),
     		BidPeriod = reader["bid_period"].ToString().Trim(),
     		TrainingType = reader["training_code_subtype"].ToString().Trim(),
     		Description = reader["training_code_name"].ToString().Trim(),
     		Location = reader["training_classloc"].ToString().Trim(),
     	});
     }
    
     reader.Close();
    
    1. Note: This requires DB models to have string parameters only.
  4. Automation SQL Tools

    1. placeholder

UI Only Tools

  1. Automation Element Manager

  2. Automation Page Manager

  3. Automation Core Driver

Tag Categories

  • Quick Links Tags are used to organize test execution. There are shared tags included in this package that should be included in all tests.

In the Visual Studio, tests are organized in a heirarchy.
{ApplicationName}.{API}.Tests
  {ApplicationName}Tests.{Production, Regession, Migration, Smoke, Functional, or BVT}
    {ApplicationName}Tests
     {FunctionName}

Example:

Cream.API.Tests
  CreamTests.BVT
    CreamBVTTests
     CreamGetPing()

  1. Shared Tags:
public const string All_E2E = "All_E2E";
public const string All_BVT = "All_BVT";
public const string All_Smoke = "All_Smoke";
public const string All_Functional = "All_Functional";
public const string All_Production = "All_Production";
public const string All_Migration = "All_Migration";
public const string All_Regression = "All_Regression";
public const string Internal_Tools = "Internal_Tools";
  1. Project Specfic Example (All projects should have each of these tags for consistency):
namespace Cream.API.Framework.Helpers
{
    public class CreamCategory
    {
        public const string Cream_API_All = "Cream_API_All";
        public const string Cream_API_BVT = "Cream_API_BVT";
        public const string Cream_API_Smoke = "Cream_API_Smoke";
        public const string Cream_API_Functional = "Cream_API_Functional";
        public const string Cream_API_Production = "Cream_API_Production";
        public const string Cream_API_Migration = "Cream_API_Migration";
        public const string Cream_API_Regression = "Cream_API_Regression";
        public const string Cream_API_Internal = "Cream_API_Internal";
        public const string Cream_API_TEST_Step_1 = "Cream_API_TEST_Step_1";
        public const string Cream_API_QA_Step_2 = "Cream_API_QA_Step_2";
        public const string Cream_API_PROD_Step_3 = "Cream_API_PROD_Step_3";
    }
}
  1. Usage examples:
/// <summary>
/// BVT Test: Validate 200 status code of GetPing API call.
/// </summary>
[Category(SharedCategory.All_BVT)]
[Category(CreamCategory.Cream_API_All)]
[Category(CreamCategory.Cream_API_BVT)]
[TestCase]
[Retry(2)]
[Repeat(1)]
public void CreamGetPing()
/// <summary>
/// Smoke Test: Validate 200 status code of GetAuthorizations API call.
/// </summary>
[Category(SharedCategory.All_Smoke)]
[Category(CreamCategory.Cream_API_All)]
[Category(CreamCategory.Cream_API_Smoke)]
[TestCase]
[Retry(2)]
[Repeat(1)]
public void GetAuthorizations()
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.5 0 6/21/2024
2.0.4 0 6/21/2024
2.0.3 36 6/20/2024
2.0.2 28 6/20/2024
2.0.1 41 6/17/2024
2.0.0 35 6/17/2024
1.9.4 47 6/4/2024
1.9.3 43 6/4/2024
1.9.2 38 6/4/2024
1.9.1 40 6/4/2024
1.9.0 40 6/1/2024
1.8.9 45 5/31/2024
1.8.8 38 5/30/2024
1.8.7 69 5/15/2024
1.8.6 63 5/10/2024
1.8.5 64 5/8/2024
1.8.4 59 5/7/2024
1.8.3 14 5/3/2024
1.8.2 231 4/5/2024
1.8.1 73 3/19/2024
1.8.0 59 3/15/2024
1.7.8 70 3/13/2024
1.7.7 56 3/13/2024
1.7.6 51 3/13/2024
1.7.5 50 3/13/2024
1.7.4 52 3/12/2024
1.7.3 55 3/12/2024
1.7.2 56 3/12/2024
1.7.1 65 3/2/2024
1.7.0 53 2/29/2024
1.6.9 55 2/29/2024
1.6.8 58 2/29/2024
1.6.7 82 2/27/2024
1.6.6 58 2/27/2024
1.6.5 54 2/26/2024
1.6.4 53 2/25/2024
1.6.3 53 2/24/2024
1.6.2 52 2/24/2024
1.6.1 51 2/24/2024
1.6.0 60 2/24/2024
1.5.9 54 2/24/2024
1.5.8 54 2/24/2024
1.5.7 56 2/24/2024
1.5.6 75 2/19/2024
1.5.5 46 2/19/2024
1.5.4 47 2/19/2024
1.5.3 47 2/19/2024
1.5.2 52 2/17/2024
1.5.1 52 2/17/2024
1.5.0 63 2/16/2024
1.4.8 50 2/16/2024
1.4.7 54 2/15/2024
1.4.6 53 2/15/2024
1.4.5 69 2/15/2024
1.4.4 72 2/13/2024
1.4.3 56 2/13/2024
1.4.2 55 2/13/2024
1.4.1 58 2/13/2024
1.4.0 62 2/9/2024
1.3.28 78 1/24/2024
1.3.27 52 1/24/2024
1.3.26 57 1/23/2024
1.3.25 54 1/23/2024
1.3.24 58 1/23/2024
1.3.23 53 1/23/2024
1.3.22 52 1/23/2024
1.3.21 52 1/23/2024
1.3.20 53 1/23/2024
1.3.19 53 1/23/2024
1.3.18 53 1/23/2024
1.3.17 60 1/23/2024
1.3.16 54 1/23/2024
1.3.15 55 1/23/2024
1.3.14 53 1/23/2024
1.3.13 61 1/23/2024
1.3.12 57 1/23/2024
1.3.11 54 1/23/2024
1.3.10 55 1/23/2024
1.3.9 53 1/23/2024
1.3.8 53 1/23/2024
1.3.7 55 1/23/2024
1.3.6 56 1/22/2024
1.3.5 57 1/22/2024
1.3.4 53 1/22/2024
1.3.3 58 1/22/2024
1.3.2 86 1/21/2024
1.3.1 58 1/21/2024
1.3.0 59 1/21/2024
1.2.9 80 1/14/2024
1.2.8 68 1/13/2024
1.2.7 65 1/13/2024
1.2.6 63 1/13/2024
1.2.5 63 1/13/2024
1.2.4 66 1/13/2024
1.2.3 75 1/12/2024
1.2.2 197 12/21/2023
1.2.1 78 12/21/2023
1.2.0 83 12/18/2023
1.1.989 62 12/15/2023
1.1.987 73 12/15/2023
1.1.986 63 12/15/2023
1.1.985 76 12/15/2023
1.1.98 69 12/15/2023
1.1.97 78 12/12/2023
1.1.96 106 12/7/2023
1.1.95 63 12/7/2023
1.1.94 85 11/30/2023
1.1.93 65 11/30/2023
1.1.92 69 11/30/2023
1.1.91 74 11/30/2023
1.1.9 107 11/9/2023
1.1.8 61 11/9/2023
1.1.7 61 11/8/2023
1.1.6 222 9/28/2023
1.1.5 121 9/28/2023
1.1.4 203 9/6/2023
1.1.3 168 8/31/2023
1.1.2 202 8/17/2023
1.1.1 150 8/10/2023
1.1.0 141 8/4/2023
1.0.9 141 8/3/2023
1.0.8 147 8/3/2023
1.0.7 137 8/3/2023
1.0.6 137 8/3/2023
1.0.5 158 7/20/2023
1.0.4 142 7/20/2023
1.0.3 351 6/5/2023
1.0.2 128 6/5/2023
1.0.1 132 6/5/2023
1.0.0 135 6/3/2023