Пример #1
0
        public async Task FindByNameCallsStoreWithNormalizedName()
        {
            // Setup
            var normalizer = MockHelpers.MockLookupNormalizer();
            var store      = new Mock <IRoleStore <PocoRole> >();
            var role       = new PocoRole {
                Name = "Foo"
            };

            store.Setup(s => s.FindByNameAsync(normalizer.NormalizeName("Foo"), CancellationToken.None)).Returns(Task.FromResult(role)).Verifiable();
            var manager = MockHelpers.TestRoleManager(store.Object);

            // Act
            var result = await manager.FindByNameAsync(role.Name);

            // Assert
            Assert.Equal(role, result);
            store.VerifyAll();
        }
Пример #2
0
        public async Task UpdateCallsStore()
        {
            // Setup
            var normalizer = MockHelpers.MockLookupNormalizer();
            var store      = new Mock <IRoleStore <PocoRole> >();
            var role       = new PocoRole {
                Name = "Foo"
            };

            store.Setup(s => s.UpdateAsync(role, CancellationToken.None)).ReturnsAsync(IdentityResult.Success).Verifiable();
            store.Setup(s => s.GetRoleNameAsync(role, CancellationToken.None)).Returns(Task.FromResult(role.Name)).Verifiable();
            store.Setup(s => s.SetNormalizedRoleNameAsync(role, normalizer.NormalizeName(role.Name), CancellationToken.None)).Returns(Task.FromResult(0)).Verifiable();
            var roleManager = MockHelpers.TestRoleManager(store.Object);

            // Act
            var result = await roleManager.UpdateAsync(role);

            // Assert
            Assert.True(result.Succeeded);
            store.VerifyAll();
        }