25 changed files with 6277 additions and 181 deletions
@ -1,25 +0,0 @@
|
||||
name: Run Development Tests |
||||
|
||||
on: |
||||
workflow_dispatch: |
||||
inputs: |
||||
logLevel: |
||||
description: 'Log level' |
||||
required: true |
||||
default: 'warning' |
||||
tags: |
||||
description: 'Test scenario tags' |
||||
|
||||
jobs: |
||||
build: |
||||
|
||||
runs-on: ubuntu-latest |
||||
|
||||
steps: |
||||
- uses: actions/checkout@v3 |
||||
- name: Setup .NET |
||||
uses: actions/setup-dotnet@v2 |
||||
with: |
||||
dotnet-version: 5.0.x |
||||
- name: Change Directory |
||||
run: cd TestAutomation | dotnet restore |dotnet build --no-restore | dotnet test --no-build --verbosity normal |
||||
@ -0,0 +1,11 @@
|
||||
# Discord bot example |
||||
|
||||
Read this [article](https://medium.freecodecamp.org/how-to-create-a-discord-bot-under-15-minutes-fb2fd0083844) to fully understand what this is about 😃 |
||||
|
||||
## Getting started |
||||
|
||||
1. Clone this repository |
||||
2. Run `npm install` |
||||
3. Grab a token on [Discord's developer portal](https://discordapp.com/developers/applications) |
||||
4. Create a `.env` file and add a `BOT_TOKEN` environmental variable whose value is the token above. |
||||
5. Run `npm run dev` |
||||
@ -0,0 +1,18 @@
|
||||
module.exports = message => { |
||||
const member = message.mentions.members.first(); |
||||
|
||||
if (!member) { |
||||
return message.reply( |
||||
`Who are you trying to kick? You must mention a user.` |
||||
); |
||||
} |
||||
|
||||
if (!member.kickable) { |
||||
return message.reply(`I can't kick this user. Sorry!`); |
||||
} |
||||
|
||||
return member |
||||
.kick() |
||||
.then(() => message.reply(`${member.user.tag} was kicked.`)) |
||||
.catch(error => message.reply(`Sorry, an error occured.`)); |
||||
}; |
||||
@ -0,0 +1,5 @@
|
||||
module.exports = (client, member) => { |
||||
member.send( |
||||
`Welcome on the server! Please be aware that we won't tolerate troll, spam or harassment. Have fun 😀` |
||||
); |
||||
}; |
||||
@ -0,0 +1,7 @@
|
||||
const kick = require("../commands/kick"); |
||||
|
||||
module.exports = (client, message) => { |
||||
if (message.content.startsWith("!kick")) { |
||||
return kick(message); |
||||
} |
||||
}; |
||||
@ -0,0 +1,3 @@
|
||||
module.exports = client => { |
||||
console.log(`Logged in as ${client.user.tag}!`); |
||||
}; |
||||
@ -0,0 +1,17 @@
|
||||
require("dotenv").config(); |
||||
const Discord = require("discord.js"); |
||||
const fs = require("fs"); |
||||
const client = new Discord.Client(); |
||||
|
||||
fs.readdir("./events/", (err, files) => { |
||||
files.forEach(file => { |
||||
const eventHandler = require(`./events/${file}`); |
||||
const eventName = file.split(".")[0]; |
||||
client.on(eventName, (...args) => eventHandler(client, ...args)); |
||||
}); |
||||
}); |
||||
|
||||
client.login(process.env.BOT_TOKEN); |
||||
|
||||
client.channels.find(x=> x.id === "969297543538311248"); |
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,20 @@
|
||||
{ |
||||
"name": "discord-bot", |
||||
"version": "1.0.0", |
||||
"description": "", |
||||
"main": "index.js", |
||||
"scripts": { |
||||
"start": "node index.js", |
||||
"dev": "nodemon index.js" |
||||
}, |
||||
"keywords": [], |
||||
"author": "", |
||||
"license": "ISC", |
||||
"dependencies": { |
||||
"discord.js": "^11.4.2", |
||||
"dotenv": "^7.0.0" |
||||
}, |
||||
"devDependencies": { |
||||
"nodemon": "^1.18.11" |
||||
} |
||||
} |
||||
Binary file not shown.
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
[{"Id":1,"Name":"Database UX Patch","Date":"2022-03-13T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":2,"Name":"Thrum Stats Hotfix","Date":"2022-03-12T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":3,"Name":"Memory Tester Patch","Date":"2022-03-01T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":4,"Name":"Hide Pyre Hotfix","Date":"2022-02-20T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":5,"Name":"Stream Patch 1","Date":"2022-02-20T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":6,"Name":"Agile UI Hotfix","Date":"2022-02-20T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":7,"Name":"Armor Patch","Date":"2022-02-19T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":8,"Name":"Home Page Patch","Date":"2022-02-19T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":9,"Name":"Mobile Menu Hotfix 2","Date":"2022-02-19T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":10,"Name":"Mobile Menu Hotfix","Date":"2022-02-19T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":11,"Name":"Mobile Menu Patch","Date":"2022-02-19T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":12,"Name":"0.0.6.8375a Patch","Date":"2022-02-18T00:00:00","GitChangeModels":[],"Important":"True"},{"Id":13,"Name":"Google Tracking Hotfix","Date":"2022-02-18T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":14,"Name":"Privacy Policy Patch","Date":"2022-02-17T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":15,"Name":"Home Page Quick Hotfix","Date":"2022-02-16T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":16,"Name":"Early Agile Patch","Date":"2022-02-16T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":17,"Name":"Form Text Rendering Hotfix","Date":"2022-02-15T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":18,"Name":"Reducing Timing Interval Hotfix","Date":"2022-02-15T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":19,"Name":"Changelog Patch","Date":"2022-02-14T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":20,"Name":"SQL Patch","Date":"2022-03-26T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":21,"Name":"Stream Patch 2","Date":"2022-03-30T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":22,"Name":"0.0.6.8900a Patch","Date":"2022-03-30T00:00:00","GitChangeModels":[],"Important":"True"},{"Id":23,"Name":"Database Links Patch","Date":"2022-04-01T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":24,"Name":"Open Source Patch","Date":"2022-04-03T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":25,"Name":"Stream Patch 3","Date":"2022-04-03T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":26,"Name":"Notes/Docs Patch","Date":"2022-04-10T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":27,"Name":"Stream Patch 4","Date":"2022-04-10T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":28,"Name":"Passive Patch","Date":"2022-04-12T00:00:00","GitChangeModels":[],"Important":"True"},{"Id":29,"Name":"0.0.6.9121a Patch","Date":"2022-04-13T00:00:00","GitChangeModels":[],"Important":"True"},{"Id":30,"Name":"Stream Patch 5","Date":"2022-04-13T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":31,"Name":"BuildCalc Hotfix","Date":"2022-04-13T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":32,"Name":"Search Patch","Date":"2022-04-16T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":33,"Name":"Search Hotfix","Date":"2022-04-16T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":34,"Name":"Stream Patch 6","Date":"2022-04-17T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":35,"Name":"v0.0.6.9201a Patch","Date":"2022-04-18T00:00:00","GitChangeModels":[],"Important":"True"},{"Id":36,"Name":"Build Calc Free Money Hotfix","Date":"2022-04-18T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":37,"Name":"BuildCalc Pyre Patch","Date":"2022-04-24T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":38,"Name":"Stream Patch 7","Date":"2022-04-24T00:00:00","GitChangeModels":[],"Important":"False"}] |
||||
[{"Id":1,"Name":"Database UX Patch","Date":"2022-03-13T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":2,"Name":"Thrum Stats Hotfix","Date":"2022-03-12T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":3,"Name":"Memory Tester Patch","Date":"2022-03-01T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":4,"Name":"Hide Pyre Hotfix","Date":"2022-02-20T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":5,"Name":"Stream Patch 1","Date":"2022-02-20T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":6,"Name":"Agile UI Hotfix","Date":"2022-02-20T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":7,"Name":"Armor Patch","Date":"2022-02-19T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":8,"Name":"Home Page Patch","Date":"2022-02-19T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":9,"Name":"Mobile Menu Hotfix 2","Date":"2022-02-19T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":10,"Name":"Mobile Menu Hotfix","Date":"2022-02-19T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":11,"Name":"Mobile Menu Patch","Date":"2022-02-19T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":12,"Name":"0.0.6.8375a Patch","Date":"2022-02-18T00:00:00","GitChangeModels":[],"Important":"True"},{"Id":13,"Name":"Google Tracking Hotfix","Date":"2022-02-18T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":14,"Name":"Privacy Policy Patch","Date":"2022-02-17T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":15,"Name":"Home Page Quick Hotfix","Date":"2022-02-16T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":16,"Name":"Early Agile Patch","Date":"2022-02-16T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":17,"Name":"Form Text Rendering Hotfix","Date":"2022-02-15T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":18,"Name":"Reducing Timing Interval Hotfix","Date":"2022-02-15T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":19,"Name":"Changelog Patch","Date":"2022-02-14T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":20,"Name":"SQL Patch","Date":"2022-03-26T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":21,"Name":"Stream Patch 2","Date":"2022-03-30T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":22,"Name":"0.0.6.8900a Patch","Date":"2022-03-30T00:00:00","GitChangeModels":[],"Important":"True"},{"Id":23,"Name":"Database Links Patch","Date":"2022-04-01T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":24,"Name":"Open Source Patch","Date":"2022-04-03T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":25,"Name":"Stream Patch 3","Date":"2022-04-03T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":26,"Name":"Notes/Docs Patch","Date":"2022-04-10T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":27,"Name":"Stream Patch 4","Date":"2022-04-10T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":28,"Name":"Passive Patch","Date":"2022-04-12T00:00:00","GitChangeModels":[],"Important":"True"},{"Id":29,"Name":"0.0.6.9121a Patch","Date":"2022-04-13T00:00:00","GitChangeModels":[],"Important":"True"},{"Id":30,"Name":"Stream Patch 5","Date":"2022-04-13T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":31,"Name":"BuildCalc Hotfix","Date":"2022-04-13T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":32,"Name":"Search Patch","Date":"2022-04-16T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":33,"Name":"Search Hotfix","Date":"2022-04-16T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":34,"Name":"Stream Patch 6","Date":"2022-04-17T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":35,"Name":"v0.0.6.9201a Patch","Date":"2022-04-18T00:00:00","GitChangeModels":[],"Important":"True"},{"Id":36,"Name":"Build Calc Free Money Hotfix","Date":"2022-04-18T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":37,"Name":"BuildCalc Pyre Patch","Date":"2022-04-24T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":38,"Name":"Stream Patch 7","Date":"2022-04-24T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":39,"Name":"Infrastructure Patch","Date":"2022-05-20T00:00:00","GitChangeModels":[],"Important":"False"}] |
||||
@ -1,13 +1,11 @@
|
||||
using OpenQA.Selenium; |
||||
using TestAutomation.Utils; |
||||
|
||||
namespace TestAutomation.Pages; |
||||
namespace TestAutomation.Pages; |
||||
|
||||
public class BasePage { |
||||
public Website website; |
||||
|
||||
public Website website; |
||||
|
||||
public BasePage(Website website) { |
||||
this.website = website; |
||||
} |
||||
|
||||
} |
||||
@ -1,119 +0,0 @@
|
||||
|
||||
namespace TestAutomation; |
||||
|
||||
public class Tests |
||||
{ |
||||
private IWebDriver _webDriver = default!; |
||||
|
||||
private readonly string localhost = "https://localhost:7234"; |
||||
private readonly string develop = "https://calm-mud-04916b210.1.azurestaticapps.net/"; |
||||
|
||||
private Website Website { get; } |
||||
|
||||
public Tests() { |
||||
var options = new FirefoxOptions(); |
||||
//var options = new ChromeOptions(); |
||||
|
||||
options.AcceptInsecureCertificates = true; |
||||
options.AddArgument("--headless"); |
||||
options.AddArgument("--ignore-certificate-errors"); |
||||
options.AddArgument("--start-maximized"); |
||||
options.AddArgument("--test-type"); |
||||
options.AddArgument("--allow-running-insecure-content"); |
||||
|
||||
//_webDriver = new FirefoxDriver(options); |
||||
//_webDriver = new ChromeDriver(Environment.CurrentDirectory, options); |
||||
_webDriver = new FirefoxDriver(Environment.CurrentDirectory, options); |
||||
|
||||
|
||||
Website = new Website(_webDriver); |
||||
} |
||||
|
||||
[OneTimeSetUp] |
||||
public void Setup() |
||||
{ |
||||
_webDriver.Navigate().GoToUrl(develop); |
||||
_webDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(15); |
||||
} |
||||
|
||||
[OneTimeTearDown] |
||||
public void TearDown() |
||||
{ |
||||
_webDriver.Quit(); |
||||
} |
||||
|
||||
[Test] |
||||
public void HarassCalculator() |
||||
{ |
||||
_webDriver.Navigate().GoToUrl(develop + "/harass-calculator"); |
||||
|
||||
int expectedTotalAlloyHarassment = 240; |
||||
|
||||
Website.HarassCalculatorPage |
||||
.SetWorkersLostToHarass(3) |
||||
.SetNumberOfTownHallsExisting(2) |
||||
.SetTownHallTravelTime(0, 30) |
||||
.GetTotalAlloyHarassment(out var foundTotalAlloyHarassment); |
||||
|
||||
Assert.True(expectedTotalAlloyHarassment.Equals(foundTotalAlloyHarassment), |
||||
$"expectTotalAlloyHarassment of {expectedTotalAlloyHarassment} " + |
||||
"does not equal " + |
||||
$"foundTotalAlloyHarassment of {foundTotalAlloyHarassment} "); |
||||
|
||||
} |
||||
|
||||
[Test] |
||||
public void HarassCalculatorInformation() |
||||
{ |
||||
_webDriver.Navigate().GoToUrl(develop + "/harass-calculator"); |
||||
|
||||
int expectedExampleTotalAlloyLoss = 720; |
||||
int expectedExampleWorkerCost = 300; |
||||
int expectedExampleMiningTimeCost = 420; |
||||
int expectedExampleTotalAlloyLossDifference = 300; |
||||
int expectedExampleTotalAlloyLossAccurate = 450; |
||||
int expectedExampleTotalAlloyLossAccurateDifference = 270; |
||||
|
||||
Website.HarassCalculatorPage |
||||
.GetExampleTotalAlloyLoss(out var foundTotalAlloyLoss) |
||||
.GetExampleWorkerCost(out var foundExampleWorkerCost) |
||||
.GetExampleMiningTimeCost(out var foundExampleMiningTimeCost) |
||||
.GetExampleTotalAlloyLossAccurate(out var foundExampleTotalAlloyLossAccurate) |
||||
.GetExampleTotalAlloyLossDifference(out var foundGetExampleTotalAlloyLossDifference) |
||||
.GetExampleTotalAlloyLossAccurateDifference(out var foundExampleTotalAlloyLossAccurateDifference); |
||||
|
||||
Assert.True(expectedExampleTotalAlloyLoss.Equals(foundTotalAlloyLoss), |
||||
$"expectedExampleTotalAlloyLoss of {expectedExampleTotalAlloyLoss} " + |
||||
"does not equal " + |
||||
$"foundTotalAlloyLoss of {foundTotalAlloyLoss} "); |
||||
|
||||
Assert.True(expectedExampleWorkerCost.Equals(foundExampleWorkerCost), |
||||
$"expectedExampleWorkerCost of {expectedExampleWorkerCost} " + |
||||
"does not equal " + |
||||
$"foundExampleWorkerCost of {foundExampleWorkerCost} "); |
||||
|
||||
|
||||
Assert.True(expectedExampleMiningTimeCost.Equals(foundExampleMiningTimeCost), |
||||
$"expectedExampleMiningTimeCost of {expectedExampleMiningTimeCost} " + |
||||
"does not equal " + |
||||
$"foundExampleMiningTimeCost of {foundExampleMiningTimeCost} "); |
||||
|
||||
|
||||
Assert.True(expectedExampleTotalAlloyLossAccurate.Equals(foundExampleTotalAlloyLossAccurate), |
||||
$"expectedExampleTotalAlloyLossAccurate of {expectedExampleTotalAlloyLossAccurate} " + |
||||
"does not equal " + |
||||
$"foundExampleTotalAlloyLossAccurate of {foundExampleTotalAlloyLossAccurate} "); |
||||
|
||||
|
||||
Assert.True(expectedExampleTotalAlloyLossDifference.Equals(foundGetExampleTotalAlloyLossDifference), |
||||
$"expectedExampleTotalAlloyLossDifference of {expectedExampleTotalAlloyLossDifference} " + |
||||
"does not equal " + |
||||
$"foundGetExampleTotalAlloyLossDifference of {foundGetExampleTotalAlloyLossDifference} "); |
||||
|
||||
|
||||
Assert.True(expectedExampleTotalAlloyLossAccurateDifference.Equals(foundExampleTotalAlloyLossAccurateDifference), |
||||
$"expectedExampleTotalAlloyLossAccurateDifference of {expectedExampleTotalAlloyLossAccurateDifference} " + |
||||
"does not equal " + |
||||
$"foundExampleTotalAlloyLossAccurateDifference of {foundExampleTotalAlloyLossAccurateDifference} "); |
||||
} |
||||
} |
||||
@ -0,0 +1,141 @@
|
||||
using System.Text; |
||||
using Newtonsoft.Json; |
||||
using TestAutomation.Utils; |
||||
|
||||
namespace TestAutomation; |
||||
|
||||
public class Tests { |
||||
private readonly IWebDriver _webDriver = default!; |
||||
private readonly string develop = "https://calm-mud-04916b210.1.azurestaticapps.net/"; |
||||
|
||||
private readonly HttpClient httpClient = new(); |
||||
|
||||
|
||||
private readonly string localhost = "https://localhost:7234"; |
||||
|
||||
private readonly TestReport testReport = new(); |
||||
|
||||
public Tests() { |
||||
var options = new FirefoxOptions(); |
||||
|
||||
options.AcceptInsecureCertificates = true; |
||||
options.AddArgument("--headless"); |
||||
options.AddArgument("--ignore-certificate-errors"); |
||||
options.AddArgument("--start-maximized"); |
||||
options.AddArgument("--test-type"); |
||||
options.AddArgument("--allow-running-insecure-content"); |
||||
|
||||
_webDriver = new FirefoxDriver(Environment.CurrentDirectory, options); |
||||
|
||||
Website = new Website(_webDriver); |
||||
} |
||||
|
||||
private Website Website { get; } |
||||
|
||||
[OneTimeSetUp] |
||||
public void Setup() { |
||||
_webDriver.Navigate().GoToUrl(develop); |
||||
_webDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(15); |
||||
} |
||||
|
||||
[OneTimeTearDown] |
||||
public void TearDown() { |
||||
_webDriver.Quit(); |
||||
|
||||
|
||||
var message = new { |
||||
content = "Test Report " + DateTime.Now.ToString("dd/MM/yyyy"), |
||||
embeds = testReport.GetMessages() |
||||
}; |
||||
|
||||
var content = new StringContent(JsonConvert.SerializeObject(message), Encoding.UTF8, "application/json"); |
||||
|
||||
httpClient.PostAsync(Environment.GetEnvironmentVariable("TEST_HOOK"), content).Wait(); |
||||
} |
||||
|
||||
[Test] |
||||
public void HarassCalculator() { |
||||
testReport.CreateTest(); |
||||
|
||||
_webDriver.Navigate().GoToUrl(develop + "/harass-calculator"); |
||||
|
||||
var expectedTotalAlloyHarassment = 240; |
||||
|
||||
try { |
||||
Website.HarassCalculatorPage |
||||
.SetWorkersLostToHarass(3) |
||||
.SetNumberOfTownHallsExisting(2) |
||||
.SetTownHallTravelTime(0, 30) |
||||
.GetTotalAlloyHarassment(out var foundTotalAlloyHarassment); |
||||
|
||||
testReport.CheckPassed(expectedTotalAlloyHarassment.Equals(foundTotalAlloyHarassment), |
||||
TestMessage.CreateFailedMessage($"expectTotalAlloyHarassment of {expectedTotalAlloyHarassment} " + |
||||
"does not equal " + |
||||
$"foundTotalAlloyHarassment of {foundTotalAlloyHarassment} ")); |
||||
} |
||||
catch (Exception e) { |
||||
testReport.CheckPassed(false, |
||||
TestMessage.CreateFailedMessage(e.StackTrace!)); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void HarassCalculatorInformation() { |
||||
testReport.CreateTest(); |
||||
|
||||
_webDriver.Navigate().GoToUrl(develop + "/harass-calculator"); |
||||
|
||||
var expectedExampleTotalAlloyLoss = 720; |
||||
var expectedExampleWorkerCost = 300; |
||||
var expectedExampleMiningTimeCost = 420; |
||||
var expectedExampleTotalAlloyLossDifference = 300; |
||||
var expectedExampleTotalAlloyLossAccurate = 450; |
||||
var expectedExampleTotalAlloyLossAccurateDifference = 270; |
||||
|
||||
Website.HarassCalculatorPage |
||||
.GetExampleTotalAlloyLoss(out var foundTotalAlloyLoss) |
||||
.GetExampleWorkerCost(out var foundExampleWorkerCost) |
||||
.GetExampleMiningTimeCost(out var foundExampleMiningTimeCost) |
||||
.GetExampleTotalAlloyLossAccurate(out var foundExampleTotalAlloyLossAccurate) |
||||
.GetExampleTotalAlloyLossDifference(out var foundGetExampleTotalAlloyLossDifference) |
||||
.GetExampleTotalAlloyLossAccurateDifference(out var foundExampleTotalAlloyLossAccurateDifference); |
||||
|
||||
testReport.CheckPassed(expectedExampleTotalAlloyLoss.Equals(foundTotalAlloyLoss), |
||||
TestMessage.CreateFailedMessage($"expectedExampleTotalAlloyLoss of {expectedExampleTotalAlloyLoss} " + |
||||
"does not equal " + |
||||
$"foundTotalAlloyLoss of {foundTotalAlloyLoss} ")); |
||||
|
||||
testReport.CheckPassed(expectedExampleWorkerCost.Equals(foundExampleWorkerCost), |
||||
TestMessage.CreateFailedMessage($"expectedExampleWorkerCost of {expectedExampleWorkerCost} " + |
||||
"does not equal " + |
||||
$"foundExampleWorkerCost of {foundExampleWorkerCost} ")); |
||||
|
||||
|
||||
testReport.CheckPassed(expectedExampleMiningTimeCost.Equals(foundExampleMiningTimeCost), |
||||
TestMessage.CreateFailedMessage($"expectedExampleMiningTimeCost of {expectedExampleMiningTimeCost} " + |
||||
"does not equal " + |
||||
$"foundExampleMiningTimeCost of {foundExampleMiningTimeCost} ")); |
||||
|
||||
|
||||
testReport.CheckPassed(expectedExampleTotalAlloyLossAccurate.Equals(foundExampleTotalAlloyLossAccurate), |
||||
TestMessage.CreateFailedMessage( |
||||
$"expectedExampleTotalAlloyLossAccurate of {expectedExampleTotalAlloyLossAccurate} " + |
||||
"does not equal " + |
||||
$"foundExampleTotalAlloyLossAccurate of {foundExampleTotalAlloyLossAccurate} ")); |
||||
|
||||
|
||||
testReport.CheckPassed(expectedExampleTotalAlloyLossDifference.Equals(foundGetExampleTotalAlloyLossDifference), |
||||
TestMessage.CreateFailedMessage( |
||||
$"expectedExampleTotalAlloyLossDifference of {expectedExampleTotalAlloyLossDifference} " + |
||||
"does not equal " + |
||||
$"foundGetExampleTotalAlloyLossDifference of {foundGetExampleTotalAlloyLossDifference} ")); |
||||
|
||||
|
||||
testReport.CheckPassed( |
||||
expectedExampleTotalAlloyLossAccurateDifference.Equals(foundExampleTotalAlloyLossAccurateDifference), |
||||
TestMessage.CreateFailedMessage( |
||||
$"expectedExampleTotalAlloyLossAccurateDifference of {expectedExampleTotalAlloyLossAccurateDifference} " + |
||||
"does not equal " + |
||||
$"foundExampleTotalAlloyLossAccurateDifference of {foundExampleTotalAlloyLossAccurateDifference} ")); |
||||
} |
||||
} |
||||
@ -0,0 +1,7 @@
|
||||
namespace TestAutomation.Utils; |
||||
|
||||
public class Test { |
||||
public string Name { get; set; } = "Name..."; |
||||
public bool Result { get; set; } = true; |
||||
public IList<TestMessage> Messages { get; set; } = new List<TestMessage>(); |
||||
} |
||||
@ -0,0 +1,11 @@
|
||||
namespace TestAutomation.Utils; |
||||
|
||||
public class TestMessage { |
||||
public string Title { get; set; } = "Name..."; |
||||
public string Description { get; set; } = ""; |
||||
public string Color { get; set; } = "FFFFFF"; |
||||
|
||||
public static TestMessage CreateFailedMessage(string description) { |
||||
return new TestMessage { Title = "Check Failed", Description = description, Color = "FF0000" }; |
||||
} |
||||
} |
||||
@ -0,0 +1,57 @@
|
||||
using System.Diagnostics; |
||||
using System.Globalization; |
||||
using System.Runtime.CompilerServices; |
||||
|
||||
namespace TestAutomation.Utils; |
||||
|
||||
public class TestReport { |
||||
private List<Test> Tests { get; } = new(); |
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)] |
||||
public Test CreateTest() { |
||||
var testName = new StackTrace().GetFrame(1)!.GetMethod()!.Name!; |
||||
Tests.Add(new Test { Name = testName }); |
||||
return Tests.Last(); |
||||
} |
||||
|
||||
public void CheckPassed(bool passed, TestMessage message) { |
||||
if (passed) return; |
||||
Tests.Last().Result = false; |
||||
Tests.Last().Messages.Add(message); |
||||
} |
||||
|
||||
public bool DidTestsPass() { |
||||
foreach (var test in Tests) { |
||||
if (test.Result) continue; |
||||
|
||||
return false; |
||||
} |
||||
|
||||
|
||||
return true; |
||||
} |
||||
|
||||
public List<object> GetMessages() { |
||||
if (DidTestsPass()) |
||||
return new List<object> { |
||||
new { |
||||
title = "Passed", |
||||
color = int.Parse("00FF00", NumberStyles.HexNumber), |
||||
description = $"All {Tests.Count} tests passed." |
||||
} |
||||
}; |
||||
|
||||
var messageList = new List<object>(); |
||||
foreach (var test in Tests) |
||||
foreach (var message in test.Messages) |
||||
messageList.Add( |
||||
new { |
||||
title = message.Title, |
||||
color = int.Parse(message.Color, NumberStyles.HexNumber), |
||||
description = message.Description |
||||
}); |
||||
|
||||
|
||||
return messageList; |
||||
} |
||||
} |
||||
@ -1,9 +1,7 @@
|
||||
global using NUnit.Framework; |
||||
|
||||
global using OpenQA.Selenium; |
||||
global using OpenQA.Selenium.Firefox; |
||||
global using OpenQA.Selenium.Chrome; |
||||
global using TestAutomation.Pages; |
||||
global using OpenQA.Selenium.Support.UI; |
||||
global using OpenQA.Selenium.Support; |
||||
|
||||
global using OpenQA.Selenium.Support; |
||||
Loading…
Reference in new issue