-
Notifications
You must be signed in to change notification settings - Fork 0
/
SLR_Bad.cs
39 lines (35 loc) · 853 Bytes
/
SLR_Bad.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System.ComponentModel.DataAnnotations;
using System.Net.Mail;
namespace SOLID_Principles.SLR
{
/// <summary>
/// mockup class for User class
/// lazy to import and using declaration
/// </summary>
public class User
{
public User(string email, string pwd) { }
}
}
namespace SOLID_Principles.SLR.Bad
{
public class UserService
{
public void Register(string email, string password)
{
if (!ValidateEmail(email))
throw new ValidationException("Email is not an email");
var user = new User(email, password);
SendEmail(new MailMessage("mysite@nowhere.com", email) { Subject = "HEllo foo" });
}
public virtual bool ValidateEmail(string email)
{
return email.Contains("@");
}
public void SendEmail(MailMessage message)
{
SmtpClient _smtpClient = new SmtpClient();
_smtpClient.Send(message);
}
}
}