Ejemplo n.º 1
0
        public async void LoginCommand_CanNotLoginWithInvalidCredentials(string username, string password)
        {
            Context.Shops.Add(new Shop()
            {
                MemberAreaUsername = username,
                MemberAreaPassword = HasherServiceMock.GetHash(password) + "difference",
                Administrator      = true,
            });
            Context.SaveChanges();

            var command = new LoginCommand()
            {
                UserName = username,
                Password = password,
            };
            await Assert.ThrowsAsync <InvalidCredentialException>(() => _handler.Handle(command, CancellationToken.None));
        }
Ejemplo n.º 2
0
        public async void LoginCommand_CanLoginWithValidCredentials(string username, string password)
        {
            var expectedId = 1;

            Context.Shops.Add(new Shop()
            {
                Id = expectedId,
                MemberAreaUsername = username,
                MemberAreaPassword = HasherServiceMock.GetHash(password),
                Administrator      = true,
            });
            Context.SaveChanges();

            var command = new LoginCommand()
            {
                UserName = username,
                Password = password,
            };

            var actualId = await _handler.Handle(command, CancellationToken.None);

            Assert.Equal(expectedId, actualId);
        }