Add single and bulk tests
This commit is contained in:
parent
136505be71
commit
e012dde28c
@ -2,6 +2,8 @@ using System;
|
|||||||
using Xunit;
|
using Xunit;
|
||||||
using Xunit.Abstractions;
|
using Xunit.Abstractions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using TeamHobby.HobbyProjectGenerator.UserManagement;
|
||||||
|
using TeamHobby.HobbyProjectGenerator.DataAccess;
|
||||||
|
|
||||||
namespace TeamHobby.UserManagement.xTests
|
namespace TeamHobby.UserManagement.xTests
|
||||||
{
|
{
|
||||||
@ -9,39 +11,100 @@ namespace TeamHobby.UserManagement.xTests
|
|||||||
{
|
{
|
||||||
|
|
||||||
ITestOutputHelper output;
|
ITestOutputHelper output;
|
||||||
public Example(ITestOutputHelper output)
|
public UnitTest1(ITestOutputHelper output)
|
||||||
{
|
{
|
||||||
this.output = output;
|
this.output = output;
|
||||||
}
|
}/*
|
||||||
[Fact]
|
[Fact]
|
||||||
public void SingleOperationinFiveSec()
|
public void SingleOperationinFiveSec()
|
||||||
{
|
{
|
||||||
DateTime start = DateTime.Now;
|
// Arrange
|
||||||
Thread.Sleep(5000);
|
DateTime sTime = DateTime.Now;
|
||||||
// create a file
|
var TestAcc = new UserAccount("newUser", "4567", "email@a.com", "regular", sTime);
|
||||||
DateTime end = DateTime.Now;
|
var serviceTest = new AccountService();
|
||||||
TimeSpan timeSpan = (end - start);
|
string dbType = "sql";
|
||||||
var sec = timeSpan.TotalSeconds;
|
RDSFactory dbFactory = new RDSFactory();
|
||||||
//throw new Exception(sec.ToString());
|
|
||||||
if (sec > 1)
|
|
||||||
{
|
|
||||||
throw new Exception("Greater than 5 seconds");
|
|
||||||
}
|
|
||||||
throw new Exception("Less than 5 seconds");
|
|
||||||
//output.WriteLine("check");
|
|
||||||
//output.WriteLine("Elapsed time is {0} ms", timeSpan.TotalSeconds);
|
|
||||||
|
|
||||||
var s = DateTime.Now;
|
|
||||||
output.WriteLine(s);
|
|
||||||
output.WriteLine("Time is ", DateTime.Now);
|
|
||||||
aTimer.Start();
|
|
||||||
|
|
||||||
Assert.True(false);
|
|
||||||
aTimer.Stop();
|
// Testing Data Access Layer
|
||||||
var e = DateTime.Now;
|
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
|
||||||
var diff = s - e;
|
"TCPIP=1;" +
|
||||||
output.WriteLine("Diff time ", diff);
|
"SERVER=localhost;" +
|
||||||
Assert.True(true);
|
"DATABASE=hobby;" +
|
||||||
|
"UID=root;" +
|
||||||
|
"PASSWORD=hobby;" +
|
||||||
|
"OPTION=3";
|
||||||
|
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
// Create a file
|
||||||
|
serviceTest.CreateUserRecord(TestAcc, "Rifat", datasource);
|
||||||
|
DateTime eTime = DateTime.Now;
|
||||||
|
TimeSpan timeDiff = (eTime - sTime);
|
||||||
|
var sec = timeDiff.TotalSeconds;
|
||||||
|
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
if (sec > 5)
|
||||||
|
{
|
||||||
|
Assert.False(false);
|
||||||
|
output.WriteLine("Greater than 5 seconds");
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Assert.True(true);
|
||||||
|
output.WriteLine("Less than 5 seconds");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
[Fact]
|
||||||
|
public void BulkOperationforSixty()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
DateTime sTime = DateTime.Now;
|
||||||
|
|
||||||
|
var serviceTest = new AccountService();
|
||||||
|
string dbType = "sql";
|
||||||
|
RDSFactory dbFactory = new RDSFactory();
|
||||||
|
|
||||||
|
|
||||||
|
// Testing Data Access Layer
|
||||||
|
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
|
||||||
|
"TCPIP=1;" +
|
||||||
|
"SERVER=localhost;" +
|
||||||
|
"DATABASE=hobby;" +
|
||||||
|
"UID=root;" +
|
||||||
|
"PASSWORD=hobby;" +
|
||||||
|
"OPTION=3";
|
||||||
|
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
// Create a file
|
||||||
|
for (int i = 0; i < 10000; i++)
|
||||||
|
{
|
||||||
|
var TestAcc = new UserAccount("newUser" + $"{i}", "4567", $"email{i}@a.com", "regular", sTime);
|
||||||
|
serviceTest.CreateUserRecord(TestAcc, "Rifat", datasource);
|
||||||
|
}
|
||||||
|
|
||||||
|
DateTime eTime = DateTime.Now;
|
||||||
|
TimeSpan timeDiff = (eTime - sTime);
|
||||||
|
var sec = timeDiff.TotalSeconds;
|
||||||
|
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
if (sec > 60)
|
||||||
|
{
|
||||||
|
Assert.False(false);
|
||||||
|
output.WriteLine("Greater than 60 seconds");
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Assert.True(true);
|
||||||
|
output.WriteLine("Less than 60 seconds");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user