Skip to content

Instantly share code, notes, and snippets.

View nakov's full-sized avatar
🎯
Focused on the global SoftUni expansion: https://softuni.org

Svetlin Nakov nakov

🎯
Focused on the global SoftUni expansion: https://softuni.org
View GitHub Profile
@nakov
nakov / FileXor.cs
Created March 10, 2021 17:50
C# Encrypt / Decrypt File with XOR
using System.IO;
void EncryptFile(string inputFile, string outputFile)
{
using (var fin = new FileStream(inputFile, FileMode.Open))
using (var fout = new FileStream(outputFile, FileMode.Create))
{
byte[] buffer = new byte[4096];
while (true)
{
@nakov
nakov / (1) script.js
Last active June 6, 2023 11:57
k6 Performance Test Script - Example
import { sleep, group, check } from "k6";
import http from "k6/http";
export let options = {
thresholds: {
// 95% of requests must finish within 500 ms & 99% within 1500 ms
http_req_duration: ['p(95) < 500', 'p(99) < 1500'],
},
};
@nakov
nakov / FormUrlEncodedContent.cs
Created February 18, 2021 20:31
Generate `x-www-form-urlencoded` content in C#
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Text;
namespace FormUrlEncodedContentExample
{
class Program
{
@nakov
nakov / MultiBrowserSeleniumTest.cs
Last active February 8, 2021 15:29
Run Selenium tests in two Web browsers in parallel with NUnit
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Remote;
using System;
namespace Selenium_Examples
{
[TestFixture(typeof(FirefoxOptions))]
@nakov
nakov / MultiSeleniumTest.cs
Last active February 8, 2021 15:29
Run Selenium tests in parallel with NUnit
[TestFixture(typeof(FirefoxOptions))]
[TestFixture(typeof(ChromeOptions))]
[Parallelizable(ParallelScope.All)]
public class MultiSeleniumTest<TOptions> where TOptions : DriverOptions, new()
{
[ThreadStatic]
private static IWebDriver driver;
[SetUp]
public void Setup()
@nakov
nakov / SeleniumTestsChrome.cs
Created January 26, 2021 17:14
XE.com Selenium automated test
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
using System;
public class SeleniumTestsChrome
{
private IWebDriver driver;
@nakov
nakov / SeleniumTests.cs
Created January 26, 2021 17:06
Selenium Basics course @ SoftUni - first homework
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;
public class SeleniumTests
{
IWebDriver driver;
[SetUp]
@nakov
nakov / XE_Selenium_Tests_ByKeyboard.cs
Created January 24, 2021 12:08
Selenium XE.com automation: convert 1 EUR to BGN and assert the rate is correct
[Test]
public void Test_XECom_EurBgnCourse_ByKeyboard()
{
driver.Navigate().GoToUrl("https://xe.com");
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
// Choose amount "1"
driver.FindElement(By.CssSelector("input#amount")).Click();
driver.FindElement(By.CssSelector("input#amount")).SendKeys("1");
@nakov
nakov / JUnitTest.java
Created January 21, 2021 17:40
GitHub API testing with Java + Maven + JUnit + UniRest
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
import junit.framework.*;
import org.json.JSONObject;
public class JUnitTest extends TestCase {
protected void setUp(){
}
@nakov
nakov / GitHubIssuesTests.cs
Created January 19, 2021 20:25
API Testing with C# (NUnit + RestSharp)
using NUnit.Framework;
using RestSharp;
using RestSharp.Authenticators;
using RestSharp.Serialization.Json;
using System;
using System.Collections.Generic;
using System.Net;
namespace API_Tests_GitHub
{