Nashtech.Core 1.0.2-beta-00001

This is a prerelease version of Nashtech.Core.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Nashtech.Core --version 1.0.2-beta-00001
NuGet\Install-Package Nashtech.Core -Version 1.0.2-beta-00001
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="Nashtech.Core" Version="1.0.2-beta-00001" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Nashtech.Core --version 1.0.2-beta-00001
#r "nuget: Nashtech.Core, 1.0.2-beta-00001"
#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 Nashtech.Core as a Cake Addin
#addin nuget:?package=Nashtech.Core&version=1.0.2-beta-00001&prerelease

// Install Nashtech.Core as a Cake Tool
#tool nuget:?package=Nashtech.Core&version=1.0.2-beta-00001&prerelease

Nashtech.Core

Calling rest API by RestSharp

As an automation tester, I want to call Apis to test that Apis or to prepare data to test the UI application. ApiRest feature base on RestSharp library, this feature helps you call a randomly Api with just 1 line of code (Actually, you have to prepare data first). For example, this is the most basic API to call

//Call an get Api wish just url
string url = "http://api.zippopotam.us/nl/3825";
IRestResponse response = ApiRest.Call(Method.GET, url);

You can call an API with full information.

//Call a Put Api with full information (header, parameter, url, body)
Dictionary<string, string> headers = new Dictionary<string, string>
{
    { "Content-Type", "application/json" }
};

Dictionary<string, object> parameters = new Dictionary<string, object>
{
    { "p", 0 }
};

string jsonBody = "{ \"createdAt\": \"2020-10-31T00:30:13.711Z\", \"name\": \"W33Haa\", \"avatar\": \"https://s3.amazonaws.com/uifaces/faces/twitter/ciaranr/33.jpg\" }";

string url = "https://5f9cbdef6dc8300016d3139b.mockapi.io/w33/users/50";

IRestResponse response = ApiRest.Call(Method.PUT, url, jsonBody, headers, parameters);

Database accessing

As an automation tester, I want to access data from databases to get data that will be used in the test cases. For example, read data from SQL server database to verify a new item that was added by calling an Api.

Access SQL server by System.Data.SqlClient

To get data from the SQL server, you have to connect to that database by Connection String and then using Query String to get data. The data will be retrieved in DataTable type. For example:

string connectionString = "Server=HN-SD-0966-WK;Database=w33;User Id=admin;Password=1;";
string queryString = "select * from Student";

SqlConnection connection = connectionString.GetConnection();
DataTable data = connection.Query(queryString);

Functions support:

//Build a new connection
SqlConnection DatabaseSqlServerAccess.GetConnection(this SqlConnectionStringBuilder sqlConnectionStringBuilder)
SqlConnection DatabaseSqlServerAccess.GetConnection(this string connectionString)
//Execute a query string
DataTable DatabaseSqlServerAccess.Query(this SqlConnection connection, string queryString)

File Reading

As an automation tester, I want to read files with various types such as json, csv, excel.

Raw text file reader by System.IO

This is the most basic type of data file and it is easy to read. To read the text file we just use the script like this example:

string filePath = "Path/to/your/text/file";
ReadText(string filePath);

Json file reader by System.IO

string filePath = "Path/to/your/json/file";
string data = FileAccess.ReadJson(filePath);

CSV file reader by System.IO

There are two types of Csv file, so we have 2 ways to get data from a CSV file. The first one is about to have headers in the 1st line so we make it is the headers of DataTable and the other lines will be the data under these headers. To get that type of data we can use the example below:

string filePath = "Path/to/your/csv/file";

//This function will read CSV have headers.
string data = FileAccess.ReadCsv(filePath);

//Or you can use this function will have the same result.
string data2 = FileAccess.ReadCsv(filePath, true);

The second type of CSV is about that file will just store value and will not have the column headers. Therefore, the DataTable result will generate the headers with the format "Column {index}" with the index will be the column number that counts from zero. To get that type of data we can use the example below:

string filePath = "Path/to/your/csv/file";

//This function will read CSV have headers.
//Set the second parameter to false will make the system know that the csv does not have the header row data.
string data2 = FileAccess.ReadCsv(filePath, false);

Excel file reader by System.IO

As same as the Cvs file, the excel file has the same structure so we still have 2 ways to get the excel file. The first one will have the first row contains headers of table and the other line will be data below that headers. Besides, there is a diffirent point compare to Csv file is that the Excel file contains many Worksheet. So, when getting that excel file we can use the script in the below example:

string filePath = "Path/to/your/excel/file";

//This is the function that help you read the excel file with worksheet index
int worksheetIndex = 0; //First worksheet item
string data = FileAccess.ReadExcel(filePath,worksheetIndex);

//This is the function that help you read the excel file with worksheet name
int worksheetName = "User"; //get data from worksheet named User
string data = FileAccess.ReadExcel(filePath,worksheetName);

The second one will contain full of data without column titles. So we will get the data from the Excel file in another way that about adds a third parameter with value "false":

string filePath = "Path/to/your/excel/file";

//This is the function that help you read the excel file with worksheet index
int worksheetIndex = 0; //first item
string data = FileAccess.ReadExcel(filePath,worksheetIndex,false);

//This is the function that help you read the excel file with worksheet name
int worksheetName = "User"; //get data from worksheet named User
string data = FileAccess.ReadExcel(filePath,worksheetName,false);

Data Assertion handling

As an automation tester, I want to verify in my automation test script that the data is returned from the application is correct or not. Therefore, the assertion is one of the most important parts of the automation testing script, it is the verify step to define the status of the script. There are two types of the assertion that consist of normal assertion (SmartAssert), soft assertion (SmartSoftAssert).

Normal assertion (SmartAssert) by FluentAssertions

SmartAssert supports some type of verifying:

AreEqual(this List<object> actual,  List<object> expected)
AreEqual(this object actual, object expected)
AreGreaterThan(this int input, int target)
AreLessThan(this int input, int target)
AreEqual(this string actual, string expected)
AreContain(this string input, string target)
IsNotNull(this object item)
IsNull(this object item)
AreEqualJson(this string actual, string expected)

This feature is pretty easy to use. To verify a list object we can just call AreEqual() function. this function can help us to compare 2 list object. Besides, the object can be a class or many other types of data such as string, int, bool, etc.

List<object> actual = ... //Init 
List<object> expected = ... //Init 

actual.AreEqual(expected)

To verify to object, the function to call still is AreEqual() and the object can be many types of data that contains class, string, int, bool.

object actual = ... //Init 
object expected = ... //Init 

actual.AreEqual(expected)

To verify an object is null or not

object actual = ... //Init

//To verify that data is not null
actual.IsNotNull()

//To verify that data is null
actual.IsNotNull()

To compare an int number with a target number

int actual = ... //Init 
int target = ... //Init

//To verify that data is greater than target data
actual.AreGreaterThan(target)

//To verify that data is less than target data
actual.AreLessThan(target)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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. 
.NET Core netcoreapp3.1 is compatible. 
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
1.0.4.6 1,309 5/12/2021
1.0.4.5 1,274 5/12/2021
1.0.4.3 1,254 5/12/2021
1.0.4.2 1,436 4/8/2021
1.0.4.1 1,521 3/29/2021
1.0.4 1,602 3/29/2021
1.0.3 1,248 3/16/2021
1.0.2 1,833 12/18/2020
1.0.2-beta-00001 887 12/17/2020
1.0.1 1,071 12/8/2020
1.0.0 1,104 12/7/2020