public void TestAddUser() { IUserAccessor accessor = this._provider.GetService <IUserAccessor>(); IUnitOfWork uow = this._provider.GetService <IUnitOfWork>(); PersistenceContext context = this._provider.GetService <PersistenceContext>(); Assert.Equal(3, context.Users.Count()); var user = new Contracts.DTO.User() { AvatarUrl = @"http://www.google.com", Email = "*****@*****.**", FirstName = "Test", LastName = "User", Location = "Any Place, USA" }; user = accessor.AddUser(user); uow.Commit(); Assert.Equal(4, context.Users.Count()); var users = context.Users.ToList(); Assert.Equal("Any Place, USA", context.Users.Where(u => u.UserId == user.UserId) .FirstOrDefault().Location); Assert.Equal(user, accessor.FindUser(user.UserId)); /* Test some bad data */ Assert.Throws <ArgumentException>(() => { accessor.AddUser(null); }); Assert.Throws <ArgumentException>(() => { accessor.AddUser(new Contracts.DTO.User() { FirstName = "Bad", LastName = "User" }); }); /* Test entry of a user with an already existing ID */ Assert.Throws <ArgumentException>(() => { accessor.AddUser(new Contracts.DTO.User() { FirstName = "Bad", LastName = "User", Location = "Death Valley", Email = "*****@*****.**", UserId = "bill" }); }); }