Esempio n. 1
0
        public async Task Can_login()
        {
            // arrange
            var user = _.MakeSaving <User>(m =>
            {
                m.ConfirmedAt    = DateTime.Now;
                m.HashedPassword = Hash.Create("123456");
            });
            var command = new AccountLogin.Command
            {
                Email    = user.Email,
                Password = "******"
            };

            // act
            await _.Send(command);

            // assert
            _.Get <IUserSession>().CurrentUserId.ShouldBe(user.Id);
        }
Esempio n. 2
0
        public async Task User_not_confirmed_registration_cannot_login()
        {
            // arrange
            var user = _.MakeSaving <User>(m =>
            {
                m.ConfirmedAt    = null;
                m.HashedPassword = Hash.Create("123456");
            });

            var command = new AccountLogin.Command
            {
                Email    = user.Email,
                Password = "******"
            };

            // act
            await Should.ThrowAsync <NotFoundException>(async() => await _.Send(command));

            // assert
            _.Get <IUserSession>().IsLogged.ShouldBeFalse();
        }