using System;
using Microsoft.VisualStudio.TestTools.LoadTesting;
using System.Net.Mail;
using System.Windows.Forms;
namespace LoadTestPluginTest
{
public class MyLoadTestPlugin : ILoadTestPlugin
{
LoadTest myLoadTest;
public void Initialize(LoadTest loadTest)
{
myLoadTest = loadTest;
myLoadTest.LoadTestFinished += new
EventHandler(myLoadTest_LoadTestFinished);
}
void myLoadTest_LoadTestFinished(object sender, EventArgs e)
{
try
{
// place custom code here
MailAddress MyAddress = new MailAddress("someone@example.com");
MailMessage MyMail = new MailMessage(MyAddress, MyAddress);
MyMail.Subject = "Load Test Finished -- Admin Email";
MyMail.Body = ((LoadTest)sender).Name + " has finished.";
SmtpClient MySmtpClient = new SmtpClient("localhost");
MySmtpClient.Send(MyMail);
}
catch (SmtpException ex)
{
MessageBox.Show(ex.InnerException.Message +
".\r\nMake sure you have a valid SMTP.", "LoadTestPlugin");
}
}
}
}