Example #1
0
        public void op_Exclude_Operation_bool()
        {
            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);
                    Recovery.Exclude(operation, false);

                    var expected = Recovery.ItemFile(operation, "Rollback").FullName;
                    foreach (var actual in Recovery.MasterFile(operation).Lines())
                    {
                        Assert.NotEqual(expected, actual);
                    }
                }
            }
            finally
            {
                Recovery.MasterDirectory = null;
            }
        }
Example #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;
            }
        }
Example #3
0
 public void op_Process_CommandLineNull_string()
 {
     using (var temp = new TempDirectory())
     {
         Assert.Throws<ArgumentNullException>(() => Program.Process(null, temp.Info.FullName));
     }
 }
Example #4
0
        public void op_Create_IEnumerableOfKeyStringDictionaryNull_FileInfo()
        {
            using (var temp = new TempDirectory())
            {
                var destination = temp.Info.ToFile("destination");

                Assert.Throws<ArgumentNullException>(() => TempCsvFile.Create(null, destination));
            }
        }
Example #5
0
        public void config()
        {
            using (var temp = new TempDirectory())
            {
                var file = temp.Info.ToFile("example.xml");
                file.Create("<list><item>example</item></list>");

                Assert.Equal("example", Config.Xml<StringList>(file).First());
            }
        }
Example #6
0
        public void op_Process_CommandLineHelp_string()
        {
            using (var temp = new TempDirectory())
            {
                var args = new List<string>
                               {
                                   "/?"
                               };

                Program.Process(CommandLine.Load(args.ToArray()), temp.Info.FullName);
            }
        }
        public void op_Load_string()
        {
            using (var temp = new TempDirectory())
            {
                var location = temp.Info.ToFile("example.csproj");
                ProjectFile.Create(location);

                var obj = ProjectCollection.Load(temp.Info.FullName);

                Assert.Equal(location.FullName, obj[0].Location.FullName);
            }
        }
Example #8
0
        public void op_Process_CommandLineInfo_string()
        {
            using (var temp = new TempDirectory())
            {
                ProjectFile.Create(temp.Info.ToFile("example.csproj"));
                var args = new List<string>
                               {
                                   "/i"
                               };

                Program.Process(CommandLine.Load(args.ToArray()), temp.Info.FullName);
            }
        }
Example #9
0
        public void op_Create_IEnumerableOfKeyStringDictionaryEmpty_FileInfo()
        {
            using (var temp = new TempDirectory())
            {
                var data = new List<KeyStringDictionary>();
                var destination = temp.Info.ToFile("destination");

                const int expected = 0;
                var actual = TempCsvFile.Create(data, destination);

                Assert.Equal(expected, actual);
            }
        }
 public void expectations_struct()
 {
     try
     {
         using (var directory = new TempDirectory())
         {
             FileRepositoryConfiguration.Mock = directory.Info;
             new RepositoryExpectations<int>().VerifyAll<FileRepository<int>>();
         }
     }
     finally
     {
         FileRepositoryConfiguration.Mock = null;
     }
 }
Example #11
0
        public void op_Create_IEnumerableOfKeyStringDictionary_FileInfo()
        {
            using (var temp = new TempDirectory())
            {
                var destination = temp.Info.ToFile("destination");
                var data = new List<KeyStringDictionary>
                               {
                                   new KeyStringDictionary
                                       {
                                           { "VALUE", "123" }
                                       }
                               };

                var count = TempCsvFile.Create(data, destination);

                Assert.True(temp.Info.ToFile("destination").Exists);
                Assert.Equal(1, count);
                Assert.Equal("123", new CsvDataSheet(destination).First()["VALUE"]);
            }
        }
        public void opIndexer_string()
        {
            using (var temp = new TempDirectory())
            {
                const string name = "example";
                var expected = temp.Info.FullName;

                var obj = new DirectoryCollection
                              {
                                  new DirectoryItem
                                      {
                                          Name = name,
                                          Value = temp.Info.FullName
                                      }
                              };

                var actual = obj[name].FullName;

                Assert.Equal(expected, actual);
            }
        }
Example #13
0
        public void op_Dispose()
        {
            TempDirectory directory = null;
            DirectoryInfo info;

            try
            {
                directory = new TempDirectory();
                info      = directory.Info;
            }
            finally
            {
                if (null != directory)
                {
                    directory.Dispose();
                }
            }

            Assert.Null(directory.Info);

            info.Refresh();
            Assert.False(info.Exists);
        }
        public void op_Create_IEnumerableOfKeyStringDictionary()
        {
            using (var temp = new TempDirectory())
            {
                var destination = temp.Info.ToFile("destination");
                var modified    = DateTime.UtcNow;
                var data        = new List <KeyStringDictionary>
                {
                    new KeyStringDictionary
                    {
                        { "VALUE", "123" }
                    }
                };

                var obj   = new DataFileCreation(destination, modified);
                var count = obj.Create(data);

                Assert.True(temp.Info.ToFile("destination").Exists);
                Assert.Equal(1, count);
                Assert.Equal(count, obj.Count);
                Assert.Equal("123", new CsvDataSheet(destination).First()["VALUE"]);
            }
        }
        public void op_LineCount_DirectoryInfo_string_SearchOption(int expected,
                                                                   int files,
                                                                   int lines,
                                                                   SearchOption searchOption)
        {
            using (var temp = new TempDirectory())
            {
                var child = temp.Info.ToDirectory("child", true);
                for (var i = 0; i < files; i++)
                {
                    var file = child.ToFile("{0}.txt".FormatWith(i));
                    file.CreateNew();
                    for (var j = 0; j < lines; j++)
                    {
                        file.AppendLine(string.Empty);
                    }
                }

                var actual = temp.Info.LineCount("*.txt", searchOption);

                Assert.Equal(expected, actual);
            }
        }
Example #16
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;
            }
        }
        public void xml_deserialize_whenEmptyType()
        {
            using (var temp = new TempDirectory())
            {
                // ReSharper disable AccessToDisposedClosure
                Assert.Throws<InvalidOperationException>(() => ("<commands>" +
                                                                "<command i='1' type=''>" +
                                                                @"<directory.create path='{0}' undo='false' />".FormatWith(temp.Info.FullName) +
                                                                "</command>" +
                                                                "</commands>").XmlDeserialize<CommandCollection>());

                // ReSharper restore AccessToDisposedClosure
            }
        }
        public void xml_serialize()
        {
            using (var temp = new TempDirectory())
            {
                var obj = new CommandCollection
                              {
                                  new DerivedCommand()
                              };

                var navigator = obj.XmlSerialize().CreateNavigator();

                Assert.True(navigator.Evaluate<bool>("1 = count(/commands/command)"));
                var xpath = "1 = count(/commands/command[@type='{0}']/command.derived[@undo='false'])".FormatWith(typeof(DerivedCommand).AssemblyQualifiedName, temp.Info.FullName);
                Assert.True(navigator.Evaluate<bool>(xpath));
            }
        }