-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
181 additions
and
59 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace TestLibrary | ||
{ | ||
public class MyCalculator | ||
{ | ||
public int Add(int a, int b) | ||
{ | ||
return a + b; | ||
} | ||
|
||
public int Subtract(int a, int b) | ||
{ | ||
return a - b; | ||
} | ||
|
||
public int Multiply(int a, int b) | ||
{ | ||
return a * b; | ||
} | ||
|
||
public int Divide(int a, int b) | ||
{ | ||
if (b == 0) | ||
throw new DivideByZeroException("Cannot divide by zero."); | ||
return a / b; | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using TestLibrary; | ||
using System; | ||
|
||
namespace UnitTestProject | ||
{ | ||
[TestClass] | ||
public class TestCalculatorMS | ||
{ | ||
private MyCalculator _calculator; | ||
Check warning on line 10 in Solution1/UnitTestProject/TestCalculatorMS.cs GitHub Actions / build_and_test
|
||
|
||
[TestInitialize] | ||
public void Setup() | ||
{ | ||
_calculator = new MyCalculator(); | ||
} | ||
|
||
[TestMethod] | ||
public void Add_ShouldReturnCorrectSum() | ||
{ | ||
// Arrange | ||
int a = 5; | ||
int b = 3; | ||
|
||
// Act | ||
int result = _calculator.Add(a, b); | ||
|
||
// Assert | ||
Assert.AreEqual(8, result); | ||
} | ||
|
||
[TestMethod] | ||
public void Subtract_ShouldReturnCorrectDifference() | ||
{ | ||
// Arrange | ||
int a = 5; | ||
int b = 3; | ||
|
||
// Act | ||
int result = _calculator.Subtract(a, b); | ||
|
||
// Assert | ||
Assert.AreEqual(2, result); | ||
} | ||
|
||
[TestMethod] | ||
public void Multiply_ShouldReturnCorrectProduct() | ||
{ | ||
// Arrange | ||
int a = 5; | ||
int b = 3; | ||
|
||
// Act | ||
int result = _calculator.Multiply(a, b); | ||
|
||
// Assert | ||
Assert.AreEqual(15, result); | ||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(DivideByZeroException))] | ||
public void Divide_ShouldThrowDivideByZeroException_WhenDividingByZero() | ||
{ | ||
// Arrange | ||
int a = 5; | ||
int b = 0; | ||
|
||
// Act | ||
_calculator.Divide(a, b); | ||
|
||
// Assert is handled by ExpectedException | ||
} | ||
|
||
[TestMethod] | ||
public void Divide_ShouldReturnCorrectQuotient() | ||
{ | ||
// Arrange | ||
int a = 6; | ||
int b = 3; | ||
|
||
// Act | ||
int result = _calculator.Divide(a, b); | ||
|
||
// Assert | ||
Assert.AreEqual(2, result); | ||
} | ||
} | ||
} | ||
|
96 changes: 48 additions & 48 deletions
96
Solution1/UnitTestProject/TestChrome.cs → Solution1/UnitTestProject/TestChromeN.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,50 @@ | ||
using System; | ||
using NUnit.Framework; | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.Chrome; | ||
namespace UnitTestProject | ||
{ | ||
public class TestChrome | ||
{ | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
// | ||
} | ||
[TearDown] | ||
public void TearDown() | ||
using System; | ||
using NUnit.Framework; | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.Chrome; | ||
namespace UnitTestProject | ||
{ | ||
public class TestChromeN | ||
{ | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
// | ||
} | ||
|
||
[Test] | ||
public void goItalle() | ||
{ | ||
var chromeOptions = new ChromeOptions(); | ||
chromeOptions.AddArguments("headless"); | ||
var driver = new ChromeDriver(chromeOptions); | ||
Console.WriteLine("open rw.italle.dk"); | ||
driver.Navigate().GoToUrl("https://rw.italle.dk"); | ||
Console.WriteLine(driver.Title); | ||
driver.FindElement(By.Name("username")).SendKeys("fang"); | ||
Assert.AreEqual(driver.Title, "HB System Login"); | ||
driver.Quit(); | ||
} | ||
|
||
[Test] | ||
public void goSoonr() | ||
{ | ||
var chromeOptions = new ChromeOptions(); | ||
chromeOptions.AddArguments("headless"); | ||
var driver = new ChromeDriver(chromeOptions); | ||
Console.WriteLine("open workplace"); | ||
driver.Navigate().GoToUrl("https://us.workplace.datto.com/login"); | ||
Console.WriteLine(driver.Title); | ||
driver.FindElement(By.Name("userName")).SendKeys("fang"); | ||
Assert.AreEqual(driver.Title, "Workplace | Sign In"); | ||
driver.Quit(); | ||
} | ||
|
||
} | ||
} | ||
} | ||
[TearDown] | ||
public void TearDown() | ||
{ | ||
// | ||
} | ||
|
||
[Test] | ||
public void goItalle() | ||
{ | ||
var chromeOptions = new ChromeOptions(); | ||
chromeOptions.AddArguments("headless"); | ||
var driver = new ChromeDriver(chromeOptions); | ||
Console.WriteLine("open rw.italle.dk"); | ||
driver.Navigate().GoToUrl("https://rw.italle.dk"); | ||
Console.WriteLine(driver.Title); | ||
driver.FindElement(By.Name("username")).SendKeys("fang"); | ||
Assert.AreEqual(driver.Title, "HB System Login"); | ||
driver.Quit(); | ||
} | ||
|
||
[Test] | ||
public void goSoonr() | ||
{ | ||
var chromeOptions = new ChromeOptions(); | ||
chromeOptions.AddArguments("headless"); | ||
var driver = new ChromeDriver(chromeOptions); | ||
Console.WriteLine("open workplace"); | ||
driver.Navigate().GoToUrl("https://us.workplace.datto.com/login"); | ||
Console.WriteLine(driver.Title); | ||
driver.FindElement(By.Name("userName")).SendKeys("fang"); | ||
Assert.AreEqual(driver.Title, "Workplace | Sign In"); | ||
driver.Quit(); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters