From bfa8cf05869fb3ec80adfbf8197b30c515553dc7 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 8 Aug 2014 12:01:02 -0700 Subject: [PATCH] Add missing merge conflict file --- .../UserManagerTest.cs | 96 ++++++++++++++++++- 1 file changed, 91 insertions(+), 5 deletions(-) diff --git a/test/Microsoft.AspNet.Identity.Test/UserManagerTest.cs b/test/Microsoft.AspNet.Identity.Test/UserManagerTest.cs index fd678c07b8..1f389c7cb7 100644 --- a/test/Microsoft.AspNet.Identity.Test/UserManagerTest.cs +++ b/test/Microsoft.AspNet.Identity.Test/UserManagerTest.cs @@ -332,6 +332,90 @@ namespace Microsoft.AspNet.Identity.Test store.VerifyAll(); } + [Fact] + public async Task AddClaimsCallsStore() + { + // Setup + var store = new Mock>(); + var user = new TestUser { UserName = "Foo" }; + var claims = new Claim[] { new Claim("1", "1"), new Claim("2", "2"), new Claim("3", "3") }; + store.Setup(s => s.AddClaimsAsync(user, claims, CancellationToken.None)) + .Returns(Task.FromResult(0)) + .Verifiable(); + store.Setup(s => s.UpdateAsync(user, CancellationToken.None)).Returns(Task.FromResult(0)).Verifiable(); + var userManager = MockHelpers.TestUserManager(store.Object); + + // Act + var result = await userManager.AddClaimsAsync(user, claims); + + // Assert + Assert.True(result.Succeeded); + store.VerifyAll(); + } + + [Fact] + public async Task AddClaimCallsStore() + { + // Setup + var store = new Mock>(); + var user = new TestUser { UserName = "Foo" }; + var claim = new Claim("1", "1"); + store.Setup(s => s.AddClaimsAsync(user, It.IsAny>(), CancellationToken.None)) + .Returns(Task.FromResult(0)) + .Verifiable(); + store.Setup(s => s.UpdateAsync(user, CancellationToken.None)).Returns(Task.FromResult(0)).Verifiable(); + var userManager = MockHelpers.TestUserManager(store.Object); + + // Act + var result = await userManager.AddClaimAsync(user, claim); + + // Assert + Assert.True(result.Succeeded); + store.VerifyAll(); + } + + [Fact] + public async Task RemoveClaimsCallsStore() + { + // Setup + var store = new Mock>(); + var user = new TestUser { UserName = "Foo" }; + var claims = new Claim[] { new Claim("1", "1"), new Claim("2", "2"), new Claim("3", "3") }; + store.Setup(s => s.RemoveClaimsAsync(user, claims, CancellationToken.None)) + .Returns(Task.FromResult(0)) + .Verifiable(); + store.Setup(s => s.UpdateAsync(user, CancellationToken.None)).Returns(Task.FromResult(0)).Verifiable(); + var userManager = MockHelpers.TestUserManager(store.Object); + + // Act + var result = await userManager.RemoveClaimsAsync(user, claims); + + // Assert + Assert.True(result.Succeeded); + store.VerifyAll(); + } + + [Fact] + public async Task RemoveClaimCallsStore() + { + // Setup + var store = new Mock>(); + var user = new TestUser { UserName = "Foo" }; + var claim = new Claim("1", "1"); + store.Setup(s => s.RemoveClaimsAsync(user, It.IsAny>(), CancellationToken.None)) + .Returns(Task.FromResult(0)) + .Verifiable(); + store.Setup(s => s.UpdateAsync(user, CancellationToken.None)).Returns(Task.FromResult(0)).Verifiable(); + var userManager = MockHelpers.TestUserManager(store.Object); + + // Act + var result = await userManager.RemoveClaimAsync(user, claim); + + // Assert + Assert.True(result.Succeeded); + store.VerifyAll(); + } + [Fact] public async Task CheckPasswordWithNullUserReturnsFalse() { @@ -515,6 +599,7 @@ namespace Microsoft.AspNet.Identity.Test await Assert.ThrowsAsync("user", async () => await manager.UpdateAsync(null)); await Assert.ThrowsAsync("user", async () => await manager.DeleteAsync(null)); await Assert.ThrowsAsync("claim", async () => await manager.AddClaimAsync(null, null)); + await Assert.ThrowsAsync("claims", async () => await manager.AddClaimsAsync(null, null)); await Assert.ThrowsAsync("userName", async () => await manager.FindByNameAsync(null)); await Assert.ThrowsAsync("userName", async () => await manager.FindByUserNamePasswordAsync(null, null)); await Assert.ThrowsAsync("login", async () => await manager.AddLoginAsync(null, null)); @@ -639,6 +724,7 @@ namespace Microsoft.AspNet.Identity.Test var manager = MockHelpers.TestUserManager(new NoopUserStore()); manager.Dispose(); await Assert.ThrowsAsync(() => manager.AddClaimAsync(null, null)); + await Assert.ThrowsAsync(() => manager.AddClaimsAsync(null, null)); await Assert.ThrowsAsync(() => manager.AddLoginAsync(null, null)); await Assert.ThrowsAsync(() => manager.AddPasswordAsync(null, null)); await Assert.ThrowsAsync(() => manager.AddToRoleAsync(null, null)); @@ -649,11 +735,11 @@ namespace Microsoft.AspNet.Identity.Test await Assert.ThrowsAsync(() => manager.GetRolesAsync(null)); await Assert.ThrowsAsync(() => manager.IsInRoleAsync(null, null)); await Assert.ThrowsAsync(() => manager.RemoveClaimAsync(null, null)); + await Assert.ThrowsAsync(() => manager.RemoveClaimsAsync(null, null)); await Assert.ThrowsAsync(() => manager.RemoveLoginAsync(null, null)); await Assert.ThrowsAsync(() => manager.RemovePasswordAsync(null)); await Assert.ThrowsAsync(() => manager.RemoveFromRoleAsync(null, null)); await Assert.ThrowsAsync(() => manager.RemoveFromRolesAsync(null, null)); - await Assert.ThrowsAsync(() => manager.RemoveClaimAsync(null, null)); await Assert.ThrowsAsync(() => manager.FindByUserNamePasswordAsync(null, null)); await Assert.ThrowsAsync(() => manager.FindByLoginAsync(null)); await Assert.ThrowsAsync(() => manager.FindByIdAsync(null)); @@ -697,12 +783,12 @@ namespace Microsoft.AspNet.Identity.Test return Task.FromResult>(new List()); } - public Task AddClaimAsync(TestUser user, Claim claim, CancellationToken cancellationToken = default(CancellationToken)) + public Task AddClaimsAsync(TestUser user, IEnumerable claim, CancellationToken cancellationToken = default(CancellationToken)) { return Task.FromResult(0); } - public Task RemoveClaimAsync(TestUser user, Claim claim, CancellationToken cancellationToken = default(CancellationToken)) + public Task RemoveClaimsAsync(TestUser user, IEnumerable claim, CancellationToken cancellationToken = default(CancellationToken)) { return Task.FromResult(0); } @@ -956,12 +1042,12 @@ namespace Microsoft.AspNet.Identity.Test throw new NotImplementedException(); } - public Task AddClaimAsync(TestUser user, Claim claim, CancellationToken cancellationToken = default(CancellationToken)) + public Task AddClaimsAsync(TestUser user, IEnumerable claims, CancellationToken cancellationToken = default(CancellationToken)) { throw new NotImplementedException(); } - public Task RemoveClaimAsync(TestUser user, Claim claim, CancellationToken cancellationToken = default(CancellationToken)) + public Task RemoveClaimsAsync(TestUser user, IEnumerable claims, CancellationToken cancellationToken = default(CancellationToken)) { throw new NotImplementedException(); }