Sie sind auf Seite 1von 4

using

using
using
using
using

System;
Microsoft.VisualStudio.TestTools.UnitTesting;
TextIt.Model;
TextIt;
System.Diagnostics;

namespace UnitTests
{
[TestClass]
public class PerformanceTests
{
//Fetch a profile of the subscriber without any change in Telco
[TestMethod]
[Timeout(1000)]
public void CleanFlow()
{
var sw = new Stopwatch(); sw.Start();
var iterations = 100;
using (var dataContext = Constant.GetDataContext())
{
for (int i = 0; i < iterations; i++)
{
var s = Subscriber.Profile("03002541119", null, dataContext)
;
}
}
sw.Stop();
Console.WriteLine("Subscriber.Profile: " + iterations + " iterations
, " + sw.ElapsedMilliseconds + " ms");
Debug.Print("Subscriber.Profile: " + iterations + " iterations, " +
sw.ElapsedMilliseconds + " ms");
}

//Fetch a profile of the subscriber without any change in Telco with cor
rect cell number as per regex
[TestMethod]
[Timeout(1000)]
public void CorrectCellNumber()
{
var sw = new Stopwatch(); sw.Start();
var iterations = 100;
using (var dataContext = Constant.GetDataContext())
{
for (int i = 0; i < iterations; i++)
{
var s = Subscriber.Profile("03002541119", null, dataContext)
;
}
}

sw.Stop();
Console.WriteLine("Subscriber.Profile: " + iterations + " iterations
, " + sw.ElapsedMilliseconds + " ms");
Debug.Print("Subscriber.Profile: " + iterations + " iterations, " +
sw.ElapsedMilliseconds + " ms");
}

//Fetch a profile of the subscriber without any change in Telco with cel
l number having spaces
[TestMethod]
[Timeout(1000)]
public void SpaceWithCellNo()
{
var sw = new Stopwatch(); sw.Start();
var iterations = 100;
using (var dataContext = Constant.GetDataContext())
{
for (int i = 0; i < iterations; i++)
{
var s = Subscriber.Profile("0300
2541119", null, dataCon
text);
}
}
sw.Stop();
Console.WriteLine("Subscriber.Profile: " + iterations + " iterations
, " + sw.ElapsedMilliseconds + " ms");
Debug.Print("Subscriber.Profile: " + iterations + " iterations, " +
sw.ElapsedMilliseconds + " ms");
}

//Fetch a profile of the subscriber without any change in Telco with inv
alid cell number
[TestMethod]
[Timeout(1000)]
public void InvalidCellNo()
{
var sw = new Stopwatch(); sw.Start();
var iterations = 100;
using (var dataContext = Constant.GetDataContext())
{
for (int i = 0; i < iterations; i++)
{
var s = Subscriber.Profile("0300-2541119", null, dataContext
);
}
}
sw.Stop();
Console.WriteLine("Subscriber.Profile: " + iterations + " iterations
, " + sw.ElapsedMilliseconds + " ms");
Debug.Print("Subscriber.Profile: " + iterations + " iterations, " +
sw.ElapsedMilliseconds + " ms");

//Fetch a profile of the subscriber without any change in Telco with inv
alid cell number
[TestMethod]
[Timeout(1000)]
public void InvalidCellNoSpCase()
{
var sw = new Stopwatch(); sw.Start();
var iterations = 100;
using (var dataContext = Constant.GetDataContext())
{
for (int i = 0; i < iterations; i++)
{
var s = Subscriber.Profile("923002541119", null, dataContext
);
}
}
sw.Stop();
Console.WriteLine("Subscriber.Profile: " + iterations + " iterations
, " + sw.ElapsedMilliseconds + " ms");
Debug.Print("Subscriber.Profile: " + iterations + " iterations, " +
sw.ElapsedMilliseconds + " ms");
}
//Fetch a profile of the subscriber with a change in Telco that is inval
id
[TestMethod]
[Timeout(1000)]
public void InvalidChangedTelco()
{
var sw = new Stopwatch(); sw.Start();
var iterations = 100;
using (var dataContext = Constant.GetDataContext())
{
for (int i = 0; i < iterations; i++)
{
var s = Subscriber.Profile("03002541119", "Unknown", dataCon
text);
}
}
sw.Stop();
Console.WriteLine("Subscriber.Profile: " + iterations + " iterations
, " + sw.ElapsedMilliseconds + " ms");
Debug.Print("Subscriber.Profile: " + iterations + " iterations, " +
sw.ElapsedMilliseconds + " ms");
}

//Fetch a profile of the subscriber with a change in a telco that is val


id

[TestMethod]
[Timeout(1000)]
public void ValidChangedTelco()
{
var sw = new Stopwatch(); sw.Start();
var iterations = 100;
using (var dataContext = Constant.GetDataContext())
{
for (int i = 0; i < iterations; i++)
{
var s = Subscriber.Profile("03002541119", "Telenor", dataCon
text);
}
}
sw.Stop();
Console.WriteLine("Subscriber.Profile: " + iterations + " iterations
, " + sw.ElapsedMilliseconds + " ms");
Debug.Print("Subscriber.Profile: " + iterations + " iterations, " +
sw.ElapsedMilliseconds + " ms");
}
//Fetch a profile of the subscriber with a change in a telco that is val
id but with 100 thousand iterations
[TestMethod]
[Timeout(1000)]
public void TooManyIterations()
{
var sw = new Stopwatch(); sw.Start();
var iterations = 100000;
using (var dataContext = Constant.GetDataContext())
{
for (int i = 0; i < iterations; i++)
{
var s = Subscriber.Profile("03002541119", "Telenor", dataCon
text);
}
}
sw.Stop();
Console.WriteLine("Subscriber.Profile: " + iterations + " iterations
, " + sw.ElapsedMilliseconds + " ms");
Debug.Print("Subscriber.Profile: " + iterations + " iterations, " +
sw.ElapsedMilliseconds + " ms");
}
}
}

Das könnte Ihnen auch gefallen