public void ToUserInfo_NullUserEntity_Throws() { UserEntity entity = null; Exception result = Assert.Throws <ArgumentException>(() => DalConverter.ToUserInfo(entity)); Assert.IsType(typeof(ArgumentException), result); }
public UserInfo GetUserByName(string userName) { UserEntity entity = Repository.GetByName(userName); if (entity == null) { return(null); } return(DalConverter.ToUserInfo(entity)); }
public void ToUserInfo_GoodUserEntity_UserInfo() { var entity = new UserEntity { Id = Guid.NewGuid(), Name = "user" }; UserInfo result = DalConverter.ToUserInfo(entity); Assert.Equal(entity.Id, result.Id); Assert.Equal(entity.Name, result.Name); }
public UserInfo LogIn(string userName) { UserEntity entity = Repository.GetByName(userName); if (entity == null) { entity = new UserEntity { Name = userName }; } entity.IsOnline = true; Repository.AddOrUpdate(entity); NotifyAboutUpdateUserState(entity); return(DalConverter.ToUserInfo(entity)); }