Пример #1
0
        public async Task <UserSignedDTO> Post(UserCreateDTO user)
        {
            user.Token = JwtTokenHelper.GenerateToken(user.Email);

            return(await ExecuteAsync(
                       () => userFacade.AddUserAsync(user),
                       (ex) => throw new BadRequestException(ex)));
        }
        public async void Should_Add_User()
        {
            //Arrange
            var userFacade = new UserFacade(new FakeSqlServerAdapter());
            var addUser    = new AddUserCommand("Yavuz", "Altun", "*****@*****.**", "4736352728");

            //Act
            var userEntity = await userFacade.AddUserAsync(addUser);

            //Assert
            Assert.Equal(addUser.FirstName, userEntity.FirstName);
        }
Пример #3
0
        public async Task TestAddUser()
        {
            var mock = new Mock <IUserRepository>();

            mock.Setup(x => x.Insert(It.IsNotNull <User>())).Callback((User user) => user.Id = guid);

            var userFacade = new UserFacade(() => mock.Object, () => CreateUoWProviderMock(), mapper);

            var signedUser = await userFacade.AddUserAsync(new UserCreateDTO()
            {
                Password = password,
                Token    = password
            });

            Assert.NotNull(signedUser);
            Assert.Equal(guid, signedUser.Id);
            Assert.NotEqual(default, signedUser.LastLoginOn);