public async Task GivenAnIdentity_ItCreatesAnExternalCredential()
            {
                // Arrange
                var authThunk = new AuthenticateThunk()
                {
                    ShimIdentity = new ClaimsIdentity(new[] {
                        new Claim(ClaimTypes.NameIdentifier, "blarg", null, "MicrosoftAccount"),
                        new Claim(ClaimTypes.Name, "bloog", null, "MicrosoftAccount")
                    })
                };
                var authService = Get<AuthenticationService>();
                var context = Fakes.CreateOwinContext();
                authThunk.Attach(context);

                // Act
                var result = await authService.ReadExternalLoginCredential(context);

                // Assert
                Assert.NotNull(result.Credential);
                Assert.Equal("external.MicrosoftAccount", result.Credential.Type);
                Assert.Equal("blarg", result.Credential.Value);
                Assert.Equal("bloog", result.Credential.Identity);
            }
            public async Task GivenNoMatchingIssuer_ItReturnsEmptyAuther()
            {
                // Arrange
                var authThunk = new AuthenticateThunk()
                {
                    ShimIdentity = new ClaimsIdentity(new[] {
                        new Claim(ClaimTypes.NameIdentifier, "blarg", null, "SomeRandomDude"),
                        new Claim(ClaimTypes.Name, "bloog", null, "SomeRandomDude")
                    })
                };
                var authService = Get<AuthenticationService>();
                var context = Fakes.CreateOwinContext();
                authThunk.Attach(context);

                // Act
                var result = await authService.ReadExternalLoginCredential(context);

                // Assert
                Assert.Same(authThunk.ShimIdentity, result.ExternalIdentity);
                Assert.Null(result.Authenticator);
            }
            public async Task GivenMatchingIssuer_ItReturnsTheAutherWithThatName()
            {
                // Arrange
                var authThunk = new AuthenticateThunk()
                {
                    ShimIdentity = new ClaimsIdentity(new[] {
                        new Claim(ClaimTypes.NameIdentifier, "blarg", null, "MicrosoftAccount"),
                        new Claim(ClaimTypes.Name, "bloog", null, "MicrosoftAccount")
                    })
                };
                var authService = Get<AuthenticationService>();
                var context = Fakes.CreateOwinContext();
                authThunk.Attach(context);

                // Act
                var result = await authService.ReadExternalLoginCredential(context);

                // Assert
                Assert.Same(authThunk.ShimIdentity, result.ExternalIdentity);
                Assert.Same(authService.Authenticators["MicrosoftAccount"], result.Authenticator);
            }
            public async Task GivenNoExternalCredentials_ItReturnsEmptyResult()
            {
                // Arrange
                var authThunk = new AuthenticateThunk();
                var authService = Get<AuthenticationService>();
                var context = Fakes.CreateOwinContext();
                authThunk.Attach(context);

                // Act
                var result = await authService.ReadExternalLoginCredential(context);

                // Assert
                Assert.Null(result.ExternalIdentity);
            }