Exemplo n.º 1
0
        public void Compare_should_detect_modified_value()
        {
            // arrange
            RegistrySnapshotComparer target;

            ChangeResult[]   expected;
            ChangeResult[]   actual;
            RegistrySnapshot lhs;
            RegistrySnapshot rhs;

            expected = new[]
            {
                new ChangeResult(ChangeType.Modification, this.FullRootKeyName + "\\Alpha", "string",
                                 RegistryValueKind.String, "alpha", "eta"),
                new ChangeResult(ChangeType.Modification, this.FullRootKeyName + "\\Alpha", "expanded_string",
                                 RegistryValueKind.ExpandString, "%systemroot%\\delta", "%systemroot%\\theta")
            };

            rhs = this.LoadBaseSnapshot();
            lhs = this.LoadChangedValueSnapshot();

            target = new RegistrySnapshotComparer(lhs, rhs);

            // act
            actual = target.Compare();

            // assert
            CollectionAssert.AreEqual(expected, actual);
        }
Exemplo n.º 2
0
        public void Compare_should_detect_new_subkey()
        {
            // arrange
            RegistrySnapshotComparer target;

            ChangeResult[]   expected;
            ChangeResult[]   actual;
            RegistrySnapshot lhs;
            RegistrySnapshot rhs;

            expected = new[]
            {
                new ChangeResult(ChangeType.Insertion, this.FullRootKeyName + "\\Gamma")
            };

            rhs = this.LoadBaseSnapshot();
            lhs = this.LoadInsertedKeySnapshot();

            target = new RegistrySnapshotComparer(lhs, rhs);

            // act
            actual = target.Compare();

            // assert
            CollectionAssert.AreEqual(expected, actual);
        }
Exemplo n.º 3
0
        public void Compare_should_detect_new_value()
        {
            // arrange
            RegistrySnapshotComparer target;

            ChangeResult[]   expected;
            ChangeResult[]   actual;
            RegistrySnapshot lhs;
            RegistrySnapshot rhs;

            expected = new[]
            {
                new ChangeResult(ChangeType.Insertion, this.FullRootKeyName + "\\Alpha", "iota",
                                 RegistryValueKind.String, "kappa", null)
            };

            rhs = this.LoadBaseSnapshot();
            lhs = this.LoadInsertedValueSnapshot();

            target = new RegistrySnapshotComparer(lhs, rhs);

            // act
            actual = target.Compare();

            // assert
            CollectionAssert.AreEqual(expected, actual);
        }
        public void Compare_should_detect_deleted_value()
        {
            // arrange
              RegistrySnapshotComparer target;
              ChangeResult[] expected;
              ChangeResult[] actual;
              RegistrySnapshot lhs;
              RegistrySnapshot rhs;

              expected = new[]
                 {
                   new ChangeResult(ChangeType.Deletion, this.FullRootKeyName + "\\Alpha", "multi_string",
                                    RegistryValueKind.MultiString, "beta\ngamma", null)
                 };

              rhs = this.LoadBaseSnapshot();
              lhs = this.LoadDeletedValueSnapshot();

              target = new RegistrySnapshotComparer(lhs, rhs);

              // act
              actual = target.Compare();

              // assert
              CollectionAssert.AreEqual(expected, actual);
        }
Exemplo n.º 5
0
        private void CompareSnapshots()
        {
            RegistrySnapshot lhs;
            RegistrySnapshot rhs;

            ChangeResult[] results;

            lhs     = null;
            rhs     = null;
            results = new ChangeResult[0];

            this.PerformAction(() => lhs = RegistrySnapshot.LoadFromFile(PathHelpers.GetFullPath(_files[0])),
                               "Loading first snapshot");
            this.PerformAction(() => rhs = RegistrySnapshot.LoadFromFile(PathHelpers.GetFullPath(_files[1])),
                               "Loading second snapshot");

            if (lhs != null && rhs != null)
            {
                this.PerformAction(() =>
                {
                    RegistrySnapshotComparer comparer;

                    comparer = new RegistrySnapshotComparer(lhs, rhs);

                    results = comparer.Compare();
                }, "Comparing snapshots");
            }

            this.PrintResults(results);

            if (this.ExitCode == ExitCode.InvalidArguments)
            {
                this.ExitCode = results.Length == 0 ? ExitCode.Success : ExitCode.CompareMismatch;
            }
        }
        public void Compare_should_detect_missing_subkey()
        {
            // arrange
              RegistrySnapshotComparer target;
              ChangeResult[] expected;
              ChangeResult[] actual;
              RegistrySnapshot lhs;
              RegistrySnapshot rhs;

              expected = new[]
                 {
                   new ChangeResult(ChangeType.Deletion, this.FullRootKeyName + "\\Beta")
                 };

              rhs = this.LoadBaseSnapshot();
              lhs = this.LoadDeletedKeySnapshot();

              target = new RegistrySnapshotComparer(lhs, rhs);

              // act
              actual = target.Compare();

              // assert
              CollectionAssert.AreEqual(expected, actual);
        }
Exemplo n.º 7
0
        public void TakeSnapshot_should_return_snapshot_of_single_key()
        {
            // arrange
            RegistrySnapshotBuilder target;
            RegistryKeySnapshot     snapshot;
            RegistryKeySnapshot     compare;
            RegistrySnapshot        lhs;
            RegistrySnapshot        rhs;

            ChangeResult[] expected;
            ChangeResult[] actual;

            target       = new RegistrySnapshotBuilder();
            compare      = this.LoadBaseSnapshot().Keys[0];
            compare.Name = "Tests";
            lhs          = new RegistrySnapshot();
            lhs.Keys.Add(compare);

            expected = new ChangeResult[0];

            this.CreateBase();

            // act
            snapshot = target.TakeSnapshot(this.FullRootKeyName);

            // assert
            rhs = new RegistrySnapshot();
            rhs.Keys.Add(snapshot);
            actual = new RegistrySnapshotComparer(lhs, rhs).Compare();
            CollectionAssert.AreEqual(expected, actual);
        }
Exemplo n.º 8
0
        private void compareBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            TaskOptions              options;
            RegistrySnapshot         lhs;
            RegistrySnapshot         rhs;
            RegistrySnapshotComparer comparer;

            options  = (TaskOptions)e.Argument;
            lhs      = RegistrySnapshot.LoadFromFile(options.FileName1);
            rhs      = RegistrySnapshot.LoadFromFile(options.FileName2);
            comparer = new RegistrySnapshotComparer(lhs, rhs);

            e.Result = comparer.Compare();
        }
Exemplo n.º 9
0
        public void Compare_should_return_no_results_when_snapshots_are_equal()
        {
            // arrange
            RegistrySnapshotComparer target;

            ChangeResult[]   expected;
            ChangeResult[]   actual;
            RegistrySnapshot lhs;
            RegistrySnapshot rhs;

            expected = new ChangeResult[0];

            rhs = this.LoadBaseSnapshot();
            lhs = this.LoadBaseSnapshot();

            target = new RegistrySnapshotComparer(lhs, rhs);

            // act
            actual = target.Compare();

            // assert
            CollectionAssert.AreEqual(expected, actual);
        }
        public void Compare_should_detect_modified_value()
        {
            // arrange
              RegistrySnapshotComparer target;
              ChangeResult[] expected;
              ChangeResult[] actual;
              RegistrySnapshot lhs;
              RegistrySnapshot rhs;

              expected = new[]
                 {
                   new ChangeResult(ChangeType.Modification, this.FullRootKeyName + "\\Alpha", "string",
                                    RegistryValueKind.String, "alpha", "eta"),
                   new ChangeResult(ChangeType.Modification, this.FullRootKeyName + "\\Alpha", "expanded_string",
                                    RegistryValueKind.ExpandString, "%systemroot%\\delta", "%systemroot%\\theta")
                 };

              rhs = this.LoadBaseSnapshot();
              lhs = this.LoadChangedValueSnapshot();

              target = new RegistrySnapshotComparer(lhs, rhs);

              // act
              actual = target.Compare();

              // assert
              CollectionAssert.AreEqual(expected, actual);
        }
        public void Compare_should_return_no_results_when_snapshots_are_equal()
        {
            // arrange
              RegistrySnapshotComparer target;
              ChangeResult[] expected;
              ChangeResult[] actual;
              RegistrySnapshot lhs;
              RegistrySnapshot rhs;

              expected = new ChangeResult[0];

              rhs = this.LoadBaseSnapshot();
              lhs = this.LoadBaseSnapshot();

              target = new RegistrySnapshotComparer(lhs, rhs);

              // act
              actual = target.Compare();

              // assert
              CollectionAssert.AreEqual(expected, actual);
        }
Exemplo n.º 12
0
    private void CompareSnapshots()
    {
      RegistrySnapshot lhs;
      RegistrySnapshot rhs;
      ChangeResult[] results;

      lhs = null;
      rhs = null;
      results = new ChangeResult[0];

      this.PerformAction(() => lhs = RegistrySnapshot.LoadFromFile(PathHelpers.GetFullPath(_files[0])),
                         "Loading first snapshot");
      this.PerformAction(() => rhs = RegistrySnapshot.LoadFromFile(PathHelpers.GetFullPath(_files[1])),
                         "Loading second snapshot");

      if (lhs != null && rhs != null)
      {
        this.PerformAction(() =>
                           {
                             RegistrySnapshotComparer comparer;

                             comparer = new RegistrySnapshotComparer(lhs, rhs);

                             results = comparer.Compare();
                           }, "Comparing snapshots");
      }

      this.PrintResults(results);

      if (this.ExitCode == ExitCode.InvalidArguments)
      {
        this.ExitCode = results.Length == 0 ? ExitCode.Success : ExitCode.CompareMismatch;
      }
    }
Exemplo n.º 13
0
        private void compareBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            TaskOptions options;
              RegistrySnapshot lhs;
              RegistrySnapshot rhs;
              RegistrySnapshotComparer comparer;

              options = (TaskOptions)e.Argument;
              lhs = RegistrySnapshot.LoadFromFile(options.FileName1);
              rhs = RegistrySnapshot.LoadFromFile(options.FileName2);
              comparer = new RegistrySnapshotComparer(lhs, rhs);

              e.Result = comparer.Compare();
        }