Toby and the mega-class deletion
So it's become obvious that having a large, all-encompassing EDMSystem class was probably not the way to go. It did give us a way to express what we wanted our acceptance tests to do, but the time has come to bite the bullet and take a look at where the system is going.
With the ProjectRepository
taking care of Create and Find for Project
, EDMSystem
can be replaced with a combination of UserService
and the repository.
[TestFixture]
public class UserServiceFixture
{
[Test]
public void OnCreationNoOneIsLoggedIn()
{
UserService userService = new UserService();
UserType currentUser = userService.CurrentUser;
Assert.Equal<UserType>(UserType.None, currentUser);
}
[Test]
public void CanSuccessfullyLoginAsAdministrator()
{
UserService userService = new UserService();
userService.LoginAs(UserType.Administrator);
Assert.Equal<UserType>(UserType.Administrator, userService.CurrentUser);
}
[Test]
public void CanSuccessfullyLoginAsNonAdministrator()
{
UserService userService = new UserService();
userService.LoginAs(UserType.Bob);
Assert.Equal<UserType>(UserType.Bob, userService.CurrentUser);
}
}
public class UserService : IUserService
{
public UserType CurrentUser
{
get { return currentUser; }
}
internal void LoginAs(UserType userType)
{
currentUser = userType;
}
private UserType currentUser;
}
public interface IUserService
{
UserType CurrentUser { get; }
}
public enum UserType
{
None,
Administrator,
Bob,
Joe
}
One small change - I added a UserType
of None
. With this new class, we can go back and update the acceptance tests. I won't bother pasting them here, but obviously EDMSystem
is gone and in its place we have a UserService
and ProjectRepository
. 10 of the 13 acceptance tests currently pass.