Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CSharpTestingExamples.ExamplePrograms
{
class ExceptionDemo1
{
public void addition(int x,int y)
{
int Res = x + y;
Console.WriteLine("Addition Result :" + Res);
}
using CSharpTestingExamples.ExamplePrograms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CSharpTestingExamples
{
class Program
{
static void Main(string[] args)
{
ExceptionDemo1 obj = new ExceptionDemo1();
obj.displayEven();
obj.addition(30, 40);
obj.substraction(120, 100);
obj.division(25, 0);
obj.multiplication(12, 10);
obj.findFactorial(4);
Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CSharpTestingExamples.ExamplePrograms
{
class ExceptionDemo1
{
public void addition(int x,int y)
{
int Res = x + y;
Console.WriteLine("Addition Result :" + Res);
}
namespace CSharpTestingExamples
{
class Program
{
static void Main(string[] args)
{
ExceptionDemo1 obj = new ExceptionDemo1();
obj.displayEven();
obj.addition(30, 40);
obj.substraction(120, 100);
obj.division(25, 0);
obj.multiplication(12, 10);
obj.findFactorial(4);
Console.ReadLine();
}
}
}
namespace CSharpTestingExamples.ExamplePrograms
{
class ExceptionDemo2
{
public int StrLengh(string str)
{
if (str==null)
{
throw new Exception("null value has given input to the
method !!!!!!!!!!");
}
return str.Length;
}
}
}
using CSharpTestingExamples.ExamplePrograms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CSharpTestingExamples
{
class Program
{
static void Main(string[] args)
{
ExceptionDemo2 obj = new ExceptionDemo2();
int val1=obj.StrLengh("program");
Console.WriteLine("# of Chars :" + val1);
try {
int val2 = obj.StrLengh(null);
Console.WriteLine("# of Chars :" + val2);
}catch(Exception e)
{
Console.WriteLine(e.Message);
}
int val3 = obj.StrLengh("Language");
Console.WriteLine("# of Chars :" + val3);
Console.ReadLine();
}
}
}
using CSharpTestingExamples.ExamplePrograms;
using OpenQA.Selenium;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium.Chrome;
using System.Threading;
namespace CSharpTestingExamples
{
class Program
{
public static IWebDriver oBrowser = null;
static void Main(string[] args)
{
intialize();
navigate();
login();
createUser();
deleteUser();
logout();
closeApplication();
}
public static void intialize()
{
oBrowser = new ChromeDriver();
Thread.Sleep(5000);
oBrowser.Manage().Window.Maximize();
}
oBrowser.FindElement(By.XPath("//*[@id='loginButton']/div")).Click();
Thread.Sleep(5000);
}
oBrowser.FindElement(By.XPath("//*[@id='topnav']/tbody/tr[1]/td[5]/a/d
iv[2]")).Click();
Thread.Sleep(4000);
oBrowser.FindElement(By.Id("gettingStartedShortcutsPanelId")).Click();
Thread.Sleep(2000);
oBrowser.FindElement(By.ClassName("buttonText")).Click();
Thread.Sleep(2000);
oBrowser.FindElement(By.Name("firstName")).SendKeys("demo");
Thread.Sleep(1000);
oBrowser.FindElement(By.Name("lastName")).SendKeys("User1");
Thread.Sleep(1000);
oBrowser.FindElement(By.Name("email")).SendKeys("demo@gmail.com");
Thread.Sleep(1000);
oBrowser.FindElement(By.Name("username")).SendKeys("demoUser1");
Thread.Sleep(1000);
oBrowser.FindElement(By.Name("password")).SendKeys("Welcome1");
Thread.Sleep(1000);
oBrowser.FindElement(By.Name("passwordCopy")).SendKeys("Welcome1");
Thread.Sleep(1000);
oBrowser.FindElement(By.ClassName("buttonTitle")).Click();
Thread.Sleep(4000);
}
oBrowser.FindElement(By.Id("userDataLightBox_deleteBtn")).Click();
Thread.Sleep(4000);
IAlert oAlert=oBrowser.SwitchTo().Alert();
oAlert.Accept();
Thread.Sleep(4000);
}
}
}