public void MergeSkipsOurLessRecentPasswordsToTarget( )
        {
            // Set up
            PasswordDigestDocument abcdUpdated = Update( TestPasswords.Abcd, new DateTime( 2011, 11, 9 ) );

            var sourcePasswords = new List<PasswordDigestDocument> { TestPasswords.Abcd, TestPasswords.Ijkl };

            var targetData = new InMemoryPasswordData( );
            targetData.SavePasswords( new List<PasswordDigestDocument> { abcdUpdated, TestPasswords.Efgh } );
            IPasswordRepository targetRepository = new PasswordRepository( targetData );

            // Exercise
            targetRepository.Merge( sourcePasswords );
            // Verify
            Assert.That( targetData.LoadPasswords( ),
                         Is.EquivalentTo( new[ ] { abcdUpdated, TestPasswords.Efgh, TestPasswords.Ijkl } ) );
        }
        public void MergeRecognizesIdenticalMasterPasswords( )
        {
            // Set up
            Guid sourceMasterPasswordId = Guid.NewGuid( );
            var sourceAbcd = WithMasterPasswordId( TestPasswords.Abcd, sourceMasterPasswordId );
            var sourceEfgh = WithMasterPasswordId( TestPasswords.Efgh, sourceMasterPasswordId );

            var sourcePasswords = new List<PasswordDigestDocument> { sourceAbcd, sourceEfgh };

            Guid targetMasterPasswordId = Guid.NewGuid( );
            var targetAbcd = WithMasterPasswordId( TestPasswords.Abcd, targetMasterPasswordId );
            var targetIjkl = WithMasterPasswordId( TestPasswords.Ijkl, targetMasterPasswordId );

            var targetData = new InMemoryPasswordData( );
            targetData.SavePasswords( new List<PasswordDigestDocument> { targetAbcd, targetIjkl } );
            IPasswordRepository targetRepository = new PasswordRepository( targetData );

            // Exercise
            targetRepository.Merge( sourcePasswords );

            // Verify
            Assert.That( targetData.LoadPasswords( ),
                         Is.EquivalentTo( new[ ] { targetAbcd, targetIjkl, WithMasterPasswordId( sourceEfgh, targetMasterPasswordId ) } ) );
        }
        public void MergeAddsOurDeletedPasswordsToTarget( )
        {
            // Set up
            var sourcePasswords = new List<PasswordDigestDocument> { TestPasswords.Abcd, TestPasswords.Ijkl };

            var targetData = new InMemoryPasswordData( );
            targetData.SavePasswords( new List<PasswordDigestDocument> { TestPasswords.Efgh } );
            IPasswordRepository targetRepository = new PasswordRepository( targetData );

            // Exercise
            targetRepository.Merge( sourcePasswords );
            // Verify
            Assert.That( targetData.LoadPasswords( ),
                         Is.EquivalentTo( new[ ] { TestPasswords.Abcd, TestPasswords.Efgh, TestPasswords.Ijkl } ) );
        }