public async Task ThrowsArgumentException_WhenUsernameIsNullOrWhitespace(string username)
            {
                var userStore = new Neo4jUserStore <IdentityUser>(GraphClient);
                var ex        = await Record.ExceptionAsync(() => userStore.FindByNameAsync(username));

                ex.Should().BeOfType <ArgumentException>();
            }
            public async Task TrimsUsernameAskedFor(string username, string expectedUsername)
            {
                var mockGraphClient = new Mock <IRawGraphClient>();
                var userStore       = new Neo4jUserStore <IdentityUser>(mockGraphClient.Object);

                await userStore.FindByNameAsync(username);

                mockGraphClient.Verify(gc => gc.ExecuteGetCypherResultsAsync <Neo4jUserStore <IdentityUser> .FindUserResult <IdentityUser> >(It.Is <CypherQuery>(actual => actual.ContainsParameter("p0", expectedUsername))), Times.Once);
            }
            public async Task LooksForEmailIgnoringCase(string email, string expectedEmail)
            {
                var mockGraphClient = new Mock <IRawGraphClient>();
                var userStore       = new Neo4jUserStore <IdentityUser>(mockGraphClient.Object);

                await userStore.FindByEmailAsync(email);

                mockGraphClient.Verify(gc => gc.ExecuteGetCypherResultsAsync <IdentityUser>(It.Is <CypherQuery>(actual => actual.ContainsParameter("p0", expectedEmail))), Times.Once);
            }
            public async Task LooksForEmailIgnoringCase(string email, string expectedEmail)
            {
                var mockGraphClient = new Mock<IRawGraphClient>();
                var userStore = new Neo4jUserStore<IdentityUser>(mockGraphClient.Object);

                await userStore.FindByEmailAsync(email);
                
                mockGraphClient.Verify(gc => gc.ExecuteGetCypherResultsAsync<IdentityUser>(It.Is<CypherQuery>(actual => actual.ContainsParameter("p0", expectedEmail))), Times.Once);
            }
            public async Task TrimsUsernameAskedFor(string username, string expectedUsername)
            {
                var mockGraphClient = new Mock<IRawGraphClient>();
                var userStore = new Neo4jUserStore<IdentityUser>(mockGraphClient.Object);

                await userStore.FindByNameAsync(username);

                mockGraphClient.Verify(gc => gc.ExecuteGetCypherResultsAsync<Neo4jUserStore<IdentityUser>.FindUserResult<IdentityUser>>(It.Is<CypherQuery>(actual => actual.ContainsParameter("p0", expectedUsername))), Times.Once);
            }
        public DatabaseFixture()
        {
            _driver  = GraphDatabase.Driver("bolt://127.0.0.1:7687", AuthTokens.Basic("neo4j", "password"));
            _session = _driver.Session();
            var identityErrorDescriber = new IdentityErrorDescriber();

            UserStore = new Neo4jUserStore <TestUser, TestRole>(_session, identityErrorDescriber);
            RoleStore = new Neo4jRoleStore <TestRole>(_session, identityErrorDescriber);
        }
示例#7
0
            public async Task DefaultLabelUsedIfPassedInIsNullOrWhiteSpace(string label)
            {
                var mockGraphClient = new Mock <IRawGraphClient>();
                var userStore       = new Neo4jUserStore <IdentityUser>(mockGraphClient.Object, label);

                await userStore.FindByEmailAsync("*****@*****.**");

                mockGraphClient.Verify(gc => gc.ExecuteGetCypherResultsAsync <IdentityUser>(It.Is <CypherQuery>(actual => actual.DebugQueryText.Contains("(u:User)"))), Times.Once);
            }
示例#8
0
            public async Task UserLabelPassedInIsUsed()
            {
                const string newUserLabel    = "Foo";
                var          mockGraphClient = new Mock <IRawGraphClient>();
                var          userStore       = new Neo4jUserStore <IdentityUser>(mockGraphClient.Object, newUserLabel);

                await userStore.FindByEmailAsync("*****@*****.**");

                mockGraphClient.Verify(gc => gc.ExecuteGetCypherResultsAsync <IdentityUser>(It.Is <CypherQuery>(actual => actual.DebugQueryText.Contains("(u:Foo)"))), Times.Once);
            }
        public async Task Throw_Disposed()
        {
            var identityErrorDescriber = new IdentityErrorDescriber();
            var store = new Neo4jUserStore <TestUser, TestRole>(new Mock <IAsyncSession>().Object, identityErrorDescriber);

            store.Dispose();

            Assert.Equal(identityErrorDescriber, store.ErrorDescriber);

            var exception = await Assert.ThrowsAsync <ObjectDisposedException>(() => store.FindByIdAsync(string.Empty, CancellationToken.None));

            Assert.Equal(exception.ObjectName, store.GetType().Name);
        }
 public async Task ThrowsArgumentException_WhenUsernameIsNullOrWhitespace(string username)
 {
     var userStore = new Neo4jUserStore<IdentityUser>(GraphClient);
     var ex = await Record.ExceptionAsync(() => userStore.FindByNameAsync(username));
     ex.Should().BeOfType<ArgumentException>();
 }