Esempio n. 1
0
        public async Task PwsFileV3_ItemData_SaveItem_StoresItemsCorrectly()
        {
            var smallItem = CreateSmallItem();
            var fullItem  = CreateFullItem();


            var ms  = new MemoryStream();
            var pws = new PwsFileV3(ms, CreatePasskey(), FileMode.Create);
            await pws.OpenAsync();


            await pws.WriteRecordAsync(smallItem);

            await pws.WriteRecordAsync(fullItem);

            pws.Dispose();

            ms.Position = 0;
            var read = (PwsFileV3)await PwsFile.OpenAsync(ms, CreatePasskey());

            var readSmallItem = await read.ReadRecordAsync();

            var readFullItem = await read.ReadRecordAsync();

            Assert.AreEqual(smallItem, readSmallItem);
            Assert.AreEqual(fullItem, readFullItem);
            //33
            File.WriteAllBytes(@"q:\Projekte_NoBackup\pwsafe\ConsoleApplication1\testcs.dat", ms.ToArray());
        }
Esempio n. 2
0
        public async Task PwsFileV3_ItemData_UnkownFields_ArePersisted()
        {
            var d1 = new ItemData();

            d1.CreateUuid();
            d1.Title    = "future";
            d1.Password = "******";
            var uv = new byte[] { 55, 42, 78, 30, 16, 93 };

            d1.SetUnknownField(Item.FieldType.UnknownTesting, uv);

            var ms  = new MemoryStream();
            var pws = new PwsFileV3(ms, CreatePasskey(), FileMode.Create);
            await pws.OpenAsync();

            await pws.WriteRecordAsync(d1);

            pws.Dispose();

            ms.Position = 0;
            var read = (PwsFileV3)await PwsFile.OpenAsync(ms, CreatePasskey());

            var item = await read.ReadRecordAsync();

            Assert.AreEqual(d1, item);
            Assert.IsNull(await read.ReadRecordAsync());
            read.Dispose();
        }