Ejemplo n.º 1
0
        public void op_Include_Operation()
        {
            try
            {
                using (var temp = new TempDirectory())
                {
                    Recovery.MasterDirectory = temp.Info.ToDirectory("Recovery");
                    var operation = new Operation(Guid.NewGuid())
                    {
                        Info = Guid.NewGuid().ToString()
                    };

                    Recovery.Include(operation);

                    var expected = Recovery.ItemFile(operation).FullName;
                    foreach (var actual in Recovery.MasterFile(operation).Lines())
                    {
                        Assert.Equal(expected, actual);
                    }
                }
            }
            finally
            {
                Recovery.MasterDirectory = null;
            }
        }
Ejemplo n.º 2
0
        public void op_Exclude_Operations_bool()
        {
            try
            {
                using (var temp = new TempDirectory())
                {
                    var resourceManager = Guid.NewGuid();
                    Recovery.MasterDirectory = temp.Info.ToDirectory("Recovery");
                    var operation1 = new Operation(resourceManager)
                    {
                        Info = Guid.NewGuid().ToString()
                    };

                    Recovery.Include(operation1);

                    var operation2 = new Operation(resourceManager)
                    {
                        Info = Guid.NewGuid().ToString()
                    };

                    Recovery.Include(operation2);
                    Recovery.Exclude(operation1, true);
                    var expected = Recovery.ItemFile(operation1, "Commit").FullName;
                    foreach (var actual in Recovery.MasterFile(operation1).Lines())
                    {
                        Assert.NotEqual(expected, actual);
                    }
                }
            }
            finally
            {
                Recovery.MasterDirectory = null;
            }
        }
Ejemplo n.º 3
0
        public void op_Include_Operations()
        {
            try
            {
                using (var temp = new TempDirectory())
                {
                    var resourceManager = Guid.NewGuid();
                    Recovery.MasterDirectory = temp.Info.ToDirectory("Recovery");
                    var operation = new Operation(resourceManager)
                    {
                        Info = Guid.NewGuid().ToString()
                    };

                    Recovery.Include(operation);
                    var first = Recovery.ItemFile(operation).FullName;
                    Assert.Equal(first, Recovery.MasterFile(operation).Lines().First());

                    operation = new Operation(resourceManager)
                    {
                        Info = Guid.NewGuid().ToString()
                    };

                    Recovery.Include(operation);
                    var last = Recovery.ItemFile(operation).FullName;
                    Assert.Equal(first, Recovery.MasterFile(operation).Lines().First());
                    Assert.Equal(last, Recovery.MasterFile(operation).Lines().Last());
                }
            }
            finally
            {
                Recovery.MasterDirectory = null;
            }
        }
Ejemplo n.º 4
0
        public virtual bool Undo()
        {
            Trace.WriteIf(Tracing.Is.TraceVerbose, "Identity.ResourceManager={0}, Identity.Instance={1}".FormatWith(Identity.ResourceManager, Identity.Instance));
            if (null == Info)
            {
                throw new InvalidOperationException();
            }

            Trace.WriteIf(Tracing.Is.TraceVerbose, "Commands.Count={0}".FormatWith(Commands.Count));
            if (0 == Commands.Count)
            {
                return(true);
            }

            foreach (var command in Commands.Reverse())
            {
                Recovery.Include(this);
                if (!command.Revert())
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 5
0
 public void op_Include_OperationNull()
 {
     Assert.Throws <ArgumentNullException>(() => Recovery.Include(null));
 }