Created
April 6, 2015 16:30
-
-
Save GeertVL-zz/f5f80f3ada31417e3dbc to your computer and use it in GitHub Desktop.
BDD with only XUnit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Xunit; | |
namespace Specs.Registration | |
{ | |
public enum UserStatus | |
{ | |
Pending | |
} | |
public class UserActivityLog | |
{ | |
public UserActivityLog() | |
{ | |
CreatedAt = DateTime.Now; | |
ID = Guid.NewGuid(); | |
} | |
public Guid ID { get; set; } | |
public Guid UserID { get; set; } | |
public string Subject { get; set; } | |
public string Entry { get; set; } | |
public DateTime CreatedAt { get; set; } | |
} | |
public class UserMailerLog | |
{ | |
public UserMailerLog() | |
{ | |
CreatedAt = DateTime.Now; | |
ID = Guid.NewGuid(); | |
} | |
public Guid ID { get; set; } | |
public Guid UserID { get; set; } | |
public string Subject { get; set; } | |
public string Body { get; set; } | |
public DateTime CreatedAt { get; set; } | |
} | |
public class User | |
{ | |
public User() | |
{ | |
ID = Guid.NewGuid(); | |
Status = UserStatus.Pending; | |
Logs = new List<UserActivityLog>(); | |
CreatedAt = DateTime.Now; | |
} | |
public string Email { get; set; } | |
public Guid ID { get; set; } | |
public UserStatus Status; | |
public ICollection<UserActivityLog> Logs { get; set; } | |
public ICollection<UserMailerLog> MailerLogs { get; set; } | |
public DateTime CreatedAt { get; set; } | |
} | |
public class Registrator | |
{ | |
public User ApplyForMembership() | |
{ | |
var user = new User(); | |
user.Logs.Add(new UserActivityLog { Subject = "Registration", Entry = "User " + user.Email + " succesfully registred", UserID = user.ID }); | |
return user; | |
} | |
} | |
[Trait("A valid application is submitted", "")] | |
public class ValidApplicationReceived | |
{ | |
Registrator _reg; | |
User _user; | |
public ValidApplicationReceived() | |
{ | |
_reg = new Registrator(); | |
_user = _reg.ApplyForMembership(); | |
} | |
[Fact] | |
public void User_Is_Add_To_System() | |
{ | |
Assert.NotNull(_user); | |
} | |
[Fact] | |
public void User_Status_Set_To_Pending() | |
{ | |
Assert.Equal(UserStatus.Pending, _user.Status); | |
} | |
[Fact] | |
public void Log_Entry_Is_Created_For_Event() | |
{ | |
Assert.Equal(1, _user.Logs.Count); | |
} | |
[Fact] | |
public void Email_Sent_To_Confirm_Address() | |
{ | |
throw new NotImplementedException("Implement me"); | |
} | |
[Fact] | |
public void A_Message_Is_Provided_For_User() | |
{ | |
throw new NotImplementedException("Implement me"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment