Beispiel #1
0
        public void QueueInsert_Nothing_Sent()
        {
            ChangePublisher changePublisher = new ChangePublisher();
            var mockItemDiscoverer = MockTestHelper.MockItemDiscoverer("source root name 1");
            changePublisher.Initialize("source root name 1",mockItemDiscoverer);

            changePublisher.QueueInsert("");

            Assert.IsNull(changePublisher.PublishPackage());
        }
Beispiel #2
0
        public void QueueOneOperationAtATime_Ok()
        {
            ChangePublisher changePublisher = new ChangePublisher();
            var mockItemDiscoverer = MockTestHelper.MockItemDiscoverer("source root name 1");
            changePublisher.Initialize("source root name 1", mockItemDiscoverer);

            changePublisher.QueueInsert("item one");

            _expectedPackageRequestResponse.ChangePushItems = new List<ChangePushItem>
                                                   {
                                                       new ChangePushItem
                                                           {
                                                               AbsolutePath = "item one",
                                                               OperationType = OperationType.Insert
                                                           }
                                                   };
            var actualPackage = changePublisher.PublishPackage();
            CompareTwoPackages(_expectedPackageRequestResponse, actualPackage);
            changePublisher.RemovePackage(actualPackage);
            Assert.IsNull(changePublisher.PublishPackage());

            changePublisher.QueueUpdate("item one");

            _expectedPackageRequestResponse.ChangePushItems = new List<ChangePushItem>
                                                   {
                                                       new ChangePushItem
                                                           {
                                                               AbsolutePath = "item one",
                                                               OperationType = OperationType.Update
                                                           }
                                                   };
            actualPackage = changePublisher.PublishPackage();
            CompareTwoPackages(_expectedPackageRequestResponse, actualPackage);
            changePublisher.RemovePackage(actualPackage);
            Assert.IsNull(changePublisher.PublishPackage());

            changePublisher.QueueDelete("item one");
            _expectedPackageRequestResponse.ChangePushItems = new List<ChangePushItem>
                                                   {
                                                       new ChangePushItem
                                                           {
                                                               AbsolutePath = "item one",
                                                               OperationType = OperationType.Delete
                                                           }
                                                   };
            actualPackage = changePublisher.PublishPackage();
            CompareTwoPackages(_expectedPackageRequestResponse, actualPackage);
            changePublisher.RemovePackage(actualPackage);
            Assert.IsNull(changePublisher.PublishPackage());
        }
 public void SaveBackup_OK()
 {
     ChangePublisher changePublisher = new ChangePublisher();
     var mockItemDiscoverer = MockTestHelper.MockItemDiscoverer("generate backup");
     changePublisher.Initialize("generate backup", mockItemDiscoverer);
     changePublisher.SaveSettingsEndExit();
 }
Beispiel #4
0
        public void SetUp()
        {
            if (File.Exists("backup.xml"))
            {
                File.Copy("backup.xml", "backup1.xml", true);
                File.Delete("backup.xml");
            }

            _expectedPackageRequestResponse = new PublishPackageRequestResponse { Source = Environment.MachineName, SourceRootName = "source root name 1" };
            _changePublisherForThreads= new ChangePublisher();
            var mockItemDiscoverer = MockTestHelper.MockItemDiscoverer("source root name 1");
            _changePublisherForThreads.Initialize("source root name 1", mockItemDiscoverer);
        }
Beispiel #5
0
        public void RemovePackage_Ok()
        {
            ChangePublisher changePublisher = new ChangePublisher();
            var mockItemDiscoverer = MockTestHelper.MockItemDiscoverer("source root name 1");

            changePublisher.Initialize("source root name 1",mockItemDiscoverer);

            changePublisher.QueueInsert("item one");

            changePublisher.QueueUpdate("item one");

            _expectedPackageRequestResponse.ChangePushItems = new List<ChangePushItem>
                                                   {
                                                       new ChangePushItem
                                                           {
                                                               AbsolutePath = "item one",
                                                               OperationType = OperationType.Update
                                                           }
                                                   };
            var publishedPackage = changePublisher.PublishPackage();

            CompareTwoPackages(_expectedPackageRequestResponse,publishedPackage);

            Assert.AreEqual(1, changePublisher.PublishedPackageNotDistributed.Count);
            Assert.AreEqual(1,changePublisher.PublishedPackageNotDistributed[0].ChangePushItems.Count);
            Assert.AreEqual(publishedPackage.PackageId,changePublisher.PublishedPackageNotDistributed[0].PackageId);
            changePublisher.RemovePackage(publishedPackage);
            Assert.AreEqual(0,changePublisher.PublishedPackageNotDistributed.Count);
        }
Beispiel #6
0
        public void RemovePackage_NoPackageSent()
        {
            ChangePublisher changePublisher = new ChangePublisher();
            var mockItemDiscoverer = MockTestHelper.MockItemDiscoverer("source root name 1");

            changePublisher.Initialize("source root name 1",mockItemDiscoverer);

            changePublisher.RemovePackage(null);
        }
Beispiel #7
0
        public void QueueUpdate_Nothing_Sent()
        {
            ChangePublisher changePublisher = new ChangePublisher( );
            var mockItemDiscoverer = MockTestHelper.MockItemDiscoverer("source root name 1");
            changePublisher.Initialize("source root name 1", mockItemDiscoverer);

            changePublisher.QueueUpdate(null);

            _expectedPackageRequestResponse.ChangePushItems = new List<ChangePushItem>();

            Assert.IsNull(changePublisher.PublishPackage());
        }
Beispiel #8
0
        public void QueueOperationsSomeDuplicates_NonThreaded_Ok()
        {
            ChangePublisher changePublisher = new ChangePublisher();
            var mockItemDiscoverer = MockTestHelper.MockItemDiscoverer("source root name 1");
            changePublisher.Initialize("source root name 1",mockItemDiscoverer);

            changePublisher.QueueInsert("item one");

            changePublisher.QueueUpdate("item one");

            _expectedPackageRequestResponse.ChangePushItems = new List<ChangePushItem>
                                                   {
                                                       new ChangePushItem
                                                           {
                                                               AbsolutePath = "item one",
                                                               OperationType = OperationType.Update
                                                           }
                                                   };
            CompareTwoPackages(_expectedPackageRequestResponse, changePublisher.PublishPackage());
        }