public void CantCreateAnyOtherType()
       {
           var factory = new KdbWriterFactory(new WinRTCrypto(),
                      new MultiThreadedBouncyCastleCrypto(),
                      new SHA256HasherRT(),
                      new GZipFactoryRT());
 
           Assert.ThrowsException<NotSupportedException>(() =>  factory.CreateWriter(null));

       }
       public void CanCreateKdb4Writer()
       {
           var factory = new KdbWriterFactory(new WinRTCrypto(),
                      new MultiThreadedBouncyCastleCrypto(),
                      new SHA256HasherRT(),
                      new GZipFactoryRT());
           var kdb4Tree = new Kdb4Tree(new XDocument());
           var writer = factory.CreateWriter(kdb4Tree);

           Assert.IsInstanceOfType(writer, typeof(Kdb4Writer));
       }
        public async Task SavePwDatabase()
        {
            var factory = new KdbWriterFactory(_encryptionEngine,
                      _keyTransformer,
                      _hasher,
                      _gzipStreamFactory);

            var writer = factory.CreateWriter(PwDatabase.Tree);  
            
#if NETFX_CORE
            IFile file = new WinRTFile(StorageFile);
#elif WP8
            IFile file = new WP8File(StorageFile);
#endif
            await writer.Write(PwDatabase, file);
        }