Пример #1
0
        public void ToUserInfo_NullUserEntity_Throws()
        {
            UserEntity entity = null;

            Exception result = Assert.Throws <ArgumentException>(() => DalConverter.ToUserInfo(entity));

            Assert.IsType(typeof(ArgumentException), result);
        }
Пример #2
0
        public UserInfo GetUserByName(string userName)
        {
            UserEntity entity = Repository.GetByName(userName);

            if (entity == null)
            {
                return(null);
            }

            return(DalConverter.ToUserInfo(entity));
        }
Пример #3
0
        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);
        }
Пример #4
0
        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));
        }