public void ReplacesExistingCredentialIfOneWithSameTypeExistsForUser()
            {
                // Arrange
                var frozenCred = new Credential("foo", "bar");
                var existingCred = new Credential("baz", "bar");
                var newCred = new Credential("baz", "boz");
                var users = new List<User>() {
                    new User("foo") { 
                        Credentials = new List<Credential>() {
                            existingCred,
                            frozenCred
                        }
                    }
                };
                var service = new TestableUserService();
                service.MockUserRepository.HasData(users);

                // Act
                service.ReplaceCredential("foo", newCred);

                // Assert
                Assert.Equal(2, users[0].Credentials.Count);
                Assert.Equal(new[] { frozenCred, newCred }, users[0].Credentials.ToArray());
                service.MockCredentialRepository
                    .Verify(x => x.DeleteOnCommit(existingCred));
                service.MockUserRepository.VerifyCommitted();
            }
            public void ThrowsExceptionIfNoUserWithProvidedUserName()
            {
                // Arrange
                var users = new List<User>() {
                    new User("foo")
                };
                var service = new TestableUserService();
                service.MockUserRepository.HasData(users);

                // Act
                var ex = Assert.Throws<InvalidOperationException>(() =>
                    service.ReplaceCredential("biz", new Credential()));

                // Assert
                Assert.Equal(Strings.UserNotFound, ex.Message);
            }