Add single and bulk tests
This commit is contained in:
parent
136505be71
commit
e012dde28c
@ -2,6 +2,8 @@ using System;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
using System.Threading;
|
||||
using TeamHobby.HobbyProjectGenerator.UserManagement;
|
||||
using TeamHobby.HobbyProjectGenerator.DataAccess;
|
||||
|
||||
namespace TeamHobby.UserManagement.xTests
|
||||
{
|
||||
@ -9,39 +11,100 @@ namespace TeamHobby.UserManagement.xTests
|
||||
{
|
||||
|
||||
ITestOutputHelper output;
|
||||
public Example(ITestOutputHelper output)
|
||||
public UnitTest1(ITestOutputHelper output)
|
||||
{
|
||||
this.output = output;
|
||||
}
|
||||
}/*
|
||||
[Fact]
|
||||
public void SingleOperationinFiveSec()
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
Thread.Sleep(5000);
|
||||
// create a file
|
||||
DateTime end = DateTime.Now;
|
||||
TimeSpan timeSpan = (end - start);
|
||||
var sec = timeSpan.TotalSeconds;
|
||||
//throw new Exception(sec.ToString());
|
||||
if (sec > 1)
|
||||
// Arrange
|
||||
DateTime sTime = DateTime.Now;
|
||||
var TestAcc = new UserAccount("newUser", "4567", "email@a.com", "regular", sTime);
|
||||
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
|
||||
serviceTest.CreateUserRecord(TestAcc, "Rifat", datasource);
|
||||
DateTime eTime = DateTime.Now;
|
||||
TimeSpan timeDiff = (eTime - sTime);
|
||||
var sec = timeDiff.TotalSeconds;
|
||||
|
||||
|
||||
// Assert
|
||||
if (sec > 5)
|
||||
{
|
||||
throw new Exception("Greater than 5 seconds");
|
||||
Assert.False(false);
|
||||
output.WriteLine("Greater than 5 seconds");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.True(true);
|
||||
output.WriteLine("Less 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();
|
||||
var e = DateTime.Now;
|
||||
var diff = s - e;
|
||||
output.WriteLine("Diff time ", diff);
|
||||
Assert.True(true);
|
||||
}
|
||||
*/
|
||||
[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