Hi,
what you want to do is to mock the calls to:
SPContext.Current.Web and
mailWeb.SiteGroups
and freturn from the second call a fake value which will probably contain a single group "members" which has a single user with some email address that will be alter verifed.
the test will go something like this:
[Test]
public void CheckEmail_ReturnMembersEmail()
{
//gere you will need to construct the fake group
//so it will contain hard coded data that will be later verifeid.
// i.e. a singlle member group with a single user with
// the "tom@gamil.com" address
SPGroupCollection fakeGroups = new SPGroupCollection();
...
...
//recording phase
using (RecorderExpectations rec = new RecorderExpectations())
{
SPWeb mailWeb = SPContext.Current.Web;
rec.ReturnDefaultImplementation();
SPGroupCollection siteGrps = mailWeb.SiteGroups;
Rec.Return(fakeGroups);
}
//test execution
testClass target = new testClass()
string actual = target.CheckEmail();
//verification
Assert.AreEqual("tom@gmail.com",actual);
MockManager.Verify();
}
Of course more tests should be constructed to check the validity of the CheckEmail() method. probably test that will check for errors, what happens when there are no groups defined, when no users defines in member group and so on.
hope this help.