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

            PublishPackageRequestResponse deletePackageRequestResponse = new PublishPackageRequestResponse
            {
                Source = "Source1",
                SourceRootName = @"Data\Test",
                ChangePushItems =
                    new List<ChangePushItem>
                                                              {
                                                                  new ChangePushItem
                                                                      {
                                                                          AbsolutePath = @"Data\Test\F1\F12\F12.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\F12.xml"));
            Assert.True(File.Exists(@"Data\Output\Test\F1\F12\F121.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\F12.xml"));
            Assert.False(File.Exists(@"Data\Output\Test\F1\F12\F121.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);
            }
        }