Пример #1
0
        public void TestCompareFilesMethodReturnFalseWhenTwoDiffrentFilesArePassedIn()
        {
            //ARRANGE
            fileStreamOne = new FileStream(fileOnePath, FileMode.Open);
            fileStreamTwo = new FileStream(fileTwoPath, FileMode.Open);
            const bool expected = true;

            //ACT
            bool actual = FileHelpers.CompareFiles(fileStreamOne, fileStreamTwo,
                                                   "<41667C9D25F55FF22D2A7A93B949D904>\n<36E081B23E919687F6F7198B39158ED>",
                                                   "<41667C9D25F55FF22D2A7A93B949D904>\n<36E081B23E919687F6F7198B39158ED>");

            //ASSERT
            Assert.AreEqual(actual, expected);

            //CLOSE STREAMS
            fileStreamOne.Close();
            fileStreamTwo.Close();
        }
Пример #2
0
        private static void Main(string[] args)
        {
            string fileOneId = String.Empty;
            string fileTwoId = String.Empty;

            if (args.Length < 1)
            {
                Console.WriteLine("Please enter a file path of two files you wish to compare");
            }
            if (args.Length == 3)
            {
                fileOneId = args[2];
                fileTwoId = args[3];
            }
            else
            {
                try
                {
                    Stream fileOneStream = new FileStream(args[0], FileMode.Open);
                    Stream fileTwoStream = new FileStream(args[1], FileMode.Open);

                    bool equal = FileHelpers.CompareFiles(fileOneStream, fileTwoStream, fileOneId, fileTwoId);
                    Console.WriteLine(equal);
                }
                catch (FileNotFoundException exception)
                {
                    LoggingHelpers.LogError(log, log.Logger.Name, exception.StackTrace, exception.Message, exception.InnerException);
                }
                catch (PathTooLongException exception)
                {
                    LoggingHelpers.LogError(log, log.Logger.Name, exception.StackTrace, exception.Message, exception.InnerException);
                }

                Console.WriteLine("Please press any key to continue");
                Console.ReadKey(true);
            }
        }