Exemple #1
0
        public void ApplyChanges_Deletes_SomeNotExist()
        {
            Subscriber changeApplyer = new Subscriber();

            PublishPackageRequestResponse deletePackageRequestResponse = new PublishPackageRequestResponse
            {
                Source = "Source1",
                SourceRootName = @"Data\Test",
                ChangePushItems =
                    new List<ChangePushItem>
                                                              {
                                                                  new ChangePushItem
                                                                      {
                                                                          AbsolutePath = @"Data\Test\F1\F12\F122.xml",
                                                                          OperationType = OperationType.Delete
                                                                      },
                                                                  new ChangePushItem
                                                                      {
                                                                          AbsolutePath = @"Data\Test\F12\F13.xml",
                                                                          OperationType = OperationType.Delete
                                                                      },
                                                                  new ChangePushItem
                                                                      {
                                                                          AbsolutePath = @"Data\Test\F1\F12\F121.xml",
                                                                          OperationType = OperationType.Delete
                                                                      }
                                                              }
            };
            changeApplyer.Initialize(@"Data\Output\Test");
            Assert.True(File.Exists(@"Data\Output\Test\F1\F12\F122.xml"));
            Assert.False(File.Exists(@"Data\Output\Test\F12\F13.xml"));
            var mockCopyStrategy = MockCopyStrategy();
            changeApplyer.CopyStrategy = mockCopyStrategy;
            foreach (var changePushItem in deletePackageRequestResponse.ChangePushItems)
            {
                var response =
                    changeApplyer.TryApplyChange(new ApplyChangePushItemRequest
                    {
                        ChangePushItem = changePushItem,
                        SourceRootName = deletePackageRequestResponse.SourceRootName
                    });
                Assert.True(response.Success);
                Assert.AreNotEqual(changePushItem.AbsolutePath, response.ChangePushItem.AbsolutePath);
            }
            Assert.False(File.Exists(@"Data\Output\Test\F1\F12\F122.xml"));
            Assert.False(File.Exists(@"Data\Output\Test\F12\F13.xml"));
        }
Exemple #2
0
        public void ApplyChanges_Upserts_SomeFail()
        {
            Subscriber changeApplyer = new Subscriber();

            PublishPackageRequestResponse insertPackageRequestResponse = new PublishPackageRequestResponse
            {
                Source = "Source1",
                SourceRootName = @"Data\Test\",
                ChangePushItems =
                    new List<ChangePushItem>
                                                              {
                                                                  new ChangePushItem
                                                                      {
                                                                          AbsolutePath = @"Data\Test\F1\F12\F11.xml",
                                                                          OperationType = OperationType.Insert
                                                                      },
                                                                  new ChangePushItem
                                                                      {
                                                                          AbsolutePath = @"Data\Test\F1\F13\F12.xml",
                                                                          OperationType = OperationType.Insert
                                                                      },
                                                                  new ChangePushItem
                                                                      {
                                                                          AbsolutePath = @"Data\Test\F1\F13\F13.xml",
                                                                          OperationType = OperationType.Update
                                                                      }

                                                              }
            };
            changeApplyer.Initialize(@"Data\Output\Test\");
            var mockCopyStrategy = MockCopyStrategy();
            changeApplyer.CopyStrategy = mockCopyStrategy;
            foreach (var changePushItem in insertPackageRequestResponse.ChangePushItems)
            {
                var response =
                    changeApplyer.TryApplyChange(new ApplyChangePushItemRequest
                    {
                        ChangePushItem = changePushItem,
                        SourceRootName = insertPackageRequestResponse.SourceRootName
                    });
                if (response.ChangePushItem.AbsolutePath == @"Data\Output\Test\F1\F13\F12.xml")
                    Assert.False(response.Success);
                else
                    Assert.True(response.Success);
                Assert.AreNotEqual(changePushItem.AbsolutePath, response.ChangePushItem.AbsolutePath);
            }
        }
Exemple #3
0
 public void Initialize_Target_NotSent()
 {
     Subscriber changeApplyer = new Subscriber();
     changeApplyer.Initialize(string.Empty);
 }
Exemple #4
0
 public void TestOnlyRemoteDataSource_Ok()
 {
     if (File.Exists(@"Data\Output\File1.xml"))
         File.Delete(@"Data\Output\File1.xml");
     Subscriber subscriber = new Subscriber();
     subscriber.Initialize(@"Data\Output");
     PublishPackageRequestResponse publishedPackageRequestResponse = new PublishPackageRequestResponse
     {
         PackageId = Guid.NewGuid(),
         Source = "SCIENDO-LAPTOP",
         SourceRootName = @"C:\MySynch.Source.Test.Root\",
         ChangePushItems =
             new List<ChangePushItem>
                                                          {
                                                              new ChangePushItem
                                                                  {
                                                                      AbsolutePath =
                                                                          @"C:\MySynch.Source.Test.Root\File1.xml",
                                                                      OperationType = OperationType.Insert
                                                                  }
                                                          }
     };
     Assert.True(subscriber.TryOpenChannel(new TryOpenChannelRequest{SourceOfDataPort=8765}).Status);
     Assert.True(subscriber.ApplyChangePushItem(new ApplyChangePushItemRequest{ChangePushItem = publishedPackageRequestResponse.ChangePushItems[0],SourceRootName=publishedPackageRequestResponse.SourceRootName}).Success);
     Assert.True(File.Exists(@"Data\Output\File1.xml"));
 }