Esempio n. 1
0
        public void TestAsyncSave()
        {
            List <UserGroup> groups = new List <UserGroup>();

            groups.Add(new UserGroup {
                creator_id = "id1", group_id = "gid1", name = "group1", description = "none"
            });
            FileStorage storage = new FileStorage(new Driver {
                email = "*****@*****.**", folder = @"resource\group1", groups = groups, session_token = "session_token1", user_id = "id1"
            });
            IAsyncResult async = storage.BeginSave("id1.jpeg", file, null, null);

            storage.EndSave(async);

            using (FileStream f = File.OpenRead(@"resource\group1\id1.jpeg"))
            {
                Assert.AreEqual(file.Length, f.Length);
                byte[] savedFile = new byte[file.Length];
                int    size      = f.Read(savedFile, 0, savedFile.Length);
                Assert.AreEqual(size, f.Length);
                for (int i = 0; i < size; i++)
                {
                    Assert.AreEqual(file[i], savedFile[i]);
                }
            }
        }