Beispiel #1
0
        public void CfConnectSyncRootTest()
        {
            const string dest        = "CfDest";
            var          destDirPath = SetupTempDir(dest);

            try
            {
                using var csp = new CloudSyncProvider(destDirPath, "TestSync");
                csp.Status    = CF_SYNC_PROVIDER_STATUS.CF_PROVIDER_STATUS_IDLE;
                csp.Status.WriteValues();

                const string desc    = "SyncStatus is good.";
                uint         descLen = (uint)(desc.Length + 1) * 2;
                var          ss      = new CF_SYNC_STATUS {
                    StructSize = (uint)Marshal.SizeOf <CF_SYNC_STATUS>() + descLen, Code = 1, DescriptionLength = descLen
                };
                var mem = new SafeHGlobalHandle(Marshal.SizeOf <CF_SYNC_STATUS>() + descLen);
                mem.Write(ss);
                StringHelper.Write(desc, ((IntPtr)mem).Offset(Marshal.SizeOf <CF_SYNC_STATUS>()), out _, true, CharSet.Unicode, descLen);
                Assert.That(CfReportSyncStatus(destDirPath, mem), ResultIs.Successful);
            }
            finally
            {
                DeleteTempDir(dest);
            }
        }
Beispiel #2
0
        public void CfCreatePlaceholdersTest()
        {
            const string dest        = "CfDest";
            const string fname       = "test.bmp";
            var          destDirPath = SetupTempDir(dest);
            var          fpath       = Path.Combine(destDirPath, fname);

            try
            {
                var tokSrc = new CancellationTokenSource();
                var token  = tokSrc.Token;
                var evt    = new ManualResetEventSlim();
                var task   = Task.Run(() =>
                {
                    using var csp = new CloudSyncProvider(destDirPath, "TestSync");

                    csp.CancelFetchData         += ShowInfo;
                    csp.CancelFetchPlaceholders += ShowInfo;
                    csp.FetchData                 += ShowInfo;
                    csp.FetchPlaceholders         += ShowInfo;
                    csp.NotifyDehydrate           += ShowInfo;
                    csp.NotifyDehydrateCompletion += ShowInfo;
                    csp.NotifyDelete              += ShowInfo;
                    csp.NotifyDeleteCompletion    += ShowInfo;
                    csp.NotifyFileCloseCompletion += ShowInfo;
                    csp.NotifyFileOpenCompletion  += ShowInfo;
                    csp.NotifyRename              += ShowInfo;
                    csp.NotifyRenameCompletion    += ShowInfo;
                    csp.ValidateData              += ShowInfo;

                    var origFileInfo = new FileInfo(TestCaseSources.BmpFile);
                    csp.CreatePlaceholderFromFile(fname, origFileInfo, true);
                    Assert.That(File.Exists(fpath), Is.True);
                    Assert.That(new FileInfo(fpath).Length, Is.EqualTo(origFileInfo.Length));

                    Debug.WriteLine("CSP is running...................................\n");
                    evt.Set();
                    while (!token.IsCancellationRequested)
                    {
                        Task.Delay(100);
                    }
Beispiel #3
0
        public void CfConnectSyncRootTest()
        {
            const string dest        = "CfDest";
            var          destDirPath = SetupTempDir(dest);

            try
            {
                using var csp = new CloudSyncProvider(destDirPath, "TestSync")
                      {
                          Status = CF_SYNC_PROVIDER_STATUS.CF_PROVIDER_STATUS_IDLE
                      };
                csp.Status.WriteValues();

                const string desc = "SyncStatus is good.";
                Assert.That(() => csp.ReportSyncStatus(desc, 1), Throws.Nothing);
            }
            finally
            {
                DeleteTempDir(dest);
            }
        }