Esempio n. 1
0
        public void DropboxClientList_ResolveByPath()
        {
            using (ShimsContext.Create())
            {
                var dbClientList = new List <DropNetClient>
                {
                    new DropNetClient("", "", "1", "client1"),
                    new DropNetClient("", "", "2", "client2"),
                    new DropNetClient("", "", "3", "client3"),
                    new DropNetClient("", "", "4", "client4"),
                };

                DropNet.Fakes.ShimDropNetClient.AllInstances.AccountInfo = client => new AccountInfo {
                    display_name = client.UserLogin.Secret, uid = long.Parse(client.UserLogin.Token)
                };                                                                  // using UserLogin Token and Secret just to differentiate between instances easily
                var d   = new DropboxClientList(dbClientList);
                var cl1 = d.ResolveByPath(@"\\client1 (1)\root\path\filename.ext"); // first client
                var cl3 = d.ResolveByPath(@"\\client3 (3)\root\path\filename.ext"); // third client
                try
                {
                    var clNotFound = d.ResolveByPath(@"\\client5 (5)\root\path\filename.ext"); // not found client
                }
                catch (Exception ex)
                {
                    Assert.IsInstanceOfType(ex, typeof(InvalidOperationException)); // we should catch 'key not in list' exception
                }
                Assert.AreEqual(dbClientList[0], cl1);
                Assert.AreEqual(dbClientList[2], cl3);
            }
        }
Esempio n. 2
0
        public void DropboxClientList_ToLocalPath()
        {
            using (ShimsContext.Create())
            {
                var dbClientList = new List <DropNetClient>
                {
                    new DropNetClient("", "", "1", "client1")
                };

                DropNet.Fakes.ShimDropNetClient.AllInstances.AccountInfo = client => new AccountInfo {
                    display_name = client.UserLogin.Secret, uid = long.Parse(client.UserLogin.Token)
                };                                                                // using UserLogin Token and Secret just to differentiate between instances easily
                var d   = new DropboxClientList(dbClientList);
                var cl1 = d.ToLocalPath(@"\\client1 (1)\root\path\filename.ext"); // first client
                Assert.AreEqual(@"\root\path\filename.ext", cl1);
            }
        }