コード例 #1
0
        public void TestMethodAssertFilesDiff04()
        {
            const string UnitTestFile1 = @"TestData\CaptureSame01.jpg";
            const string UnitTestFile2 = @"TestData\CaptureSame02.jpg";

            Assert.IsTrue(StfAssert.FilesDoNotDiffer("TestStepName 1", UnitTestFile1, UnitTestFile2));
            Assert.IsFalse(StfAssert.FilesDoDiffer("TestStepName 1", UnitTestFile1, UnitTestFile2));
        }
コード例 #2
0
        public void TestMethodAssertFilesDiff03()
        {
            const string UnitTestFile1 = @"TestData\zerofile.txt";
            const string UnitTestFile2 = @"TestData\OneCharFile.txt";

            Assert.IsTrue(StfAssert.FilesDoDiffer("TestStepName 1", UnitTestFile1, UnitTestFile2));
            Assert.IsFalse(StfAssert.FilesDoNotDiffer("TestStepName 1", UnitTestFile1, UnitTestFile2));
        }
コード例 #3
0
        public void TestMethodAssertFilesDiffer01()
        {
            const string UnitTestFile1 = @"TestData\TestMethodAssertFileNotExists1.xml";
            const string UnitTestFile2 = @"TestData\TestMethodAssertFileNotExists2.xml";

            Assert.IsTrue(StfAssert.FilesDoDiffer("TestStepName 1", UnitTestFile1, UnitTestFile2));
            Assert.IsFalse(StfAssert.FilesDoNotDiffer("TestStepName 1", UnitTestFile1, UnitTestFile2));

            // null and empty strings returns false
            Assert.IsFalse(StfAssert.FileContains("filename1 null, filename2 Null", null, null));
            Assert.IsFalse(StfAssert.FileContains("filename1 null, filename2 Empty", null, string.Empty));
            Assert.IsFalse(StfAssert.FileContains("filename1 null, filename2 notNull", null, UnitTestFile1));
            Assert.IsFalse(StfAssert.FileContains("filename1 Empty, filename2 Null", string.Empty, null));
            Assert.IsFalse(StfAssert.FileContains("filename1 Empty, filename2 Empty", string.Empty, string.Empty));
            Assert.IsFalse(StfAssert.FileContains("filename1 Empty, filename2 notNull", string.Empty, UnitTestFile1));
            Assert.IsFalse(StfAssert.FileContains("filename1 null, filename2 Null", UnitTestFile1, null));
            Assert.IsFalse(StfAssert.FileContains("filename1 null, filename2 Empty", UnitTestFile1, string.Empty));
            Assert.IsFalse(StfAssert.FileContains("filename1 null, filename2 notNull", UnitTestFile1, "A string"));
        }
コード例 #4
0
        /// <summary>
        /// The helper read key value pairs from file.
        /// </summary>
        /// <param name="testStep">
        /// The test step.
        /// </param>
        /// <param name="inputFilename">
        /// The input filename.
        /// </param>
        /// <param name="assignmentOperator">
        /// The assignment operator.
        /// </param>
        /// <param name="commentIndicator">
        /// The comment indicator.
        /// </param>
        /// <param name="keyNameIgnoreCase">
        /// The key name ignore case.
        /// </param>
        private void HelperReadKeyValuePairsFromFile(string testStep, string inputFilename, string assignmentOperator = "=", string commentIndicator = "//", bool keyNameIgnoreCase = true)
        {
            StfLogger.LogHeader(testStep);

            var absolutePathInput    = stfTestUtils.GetTestCaseRootFilePath(inputFilename);
            var absolutePathExpected = stfTestUtils.GetTestCaseRootFilePath($@"Expected\{inputFilename}");
            var tempInputPath        = stfTestUtils.GetTestCaseTempFilePath(inputFilename, false);
            var tempActualPath       = stfTestUtils.GetTestCaseTempFilePath($@"{inputFilename}-Actual.txt", false);
            var tempExpectedPath     = stfTestUtils.GetTestCaseTempFilePath($@"{inputFilename}-Expected.txt", false);
            var fileUtils            = stfTestUtils.FileUtils;

            fileUtils.CopyFile(absolutePathInput, tempInputPath);
            fileUtils.CopyFile(absolutePathExpected, tempExpectedPath);

            // generate Actual
            var keyNameValueUtils = new KeyValuePairUtils(assignmentOperator, commentIndicator, keyNameIgnoreCase);
            var keyValuePairs     = keyNameValueUtils.ReadKeyValuePairsFromFile(tempInputPath);

            keyNameValueUtils.SaveKeyValuePairsToFile(tempActualPath, keyValuePairs);

            StfAssert.FilesDoNotDiffer(testStep, tempExpectedPath, tempActualPath);
        }
コード例 #5
0
        /// <summary>
        /// The helper get clean file content.
        /// </summary>
        /// <param name="testStep">
        /// The test step.
        /// </param>
        /// <param name="inputFilename">
        /// The input filename.
        /// </param>
        private void HelperGetCleanFileContent(string testStep, string inputFilename)
        {
            StfLogger.LogHeader(testStep);

            var expectedFilename     = $"{inputFilename}.Expected.txt";
            var absolutePathInput    = stfTestUtils.GetTestCaseRootFilePath(inputFilename);
            var absolutePathExpected = stfTestUtils.GetTestCaseRootFilePath(expectedFilename);
            var tempInputPath        = stfTestUtils.GetTestCaseTempFilePath(inputFilename, false);
            var tempActualPath       = stfTestUtils.GetTestCaseTempFilePath($@"{inputFilename}-Actual.txt", false);
            var tempExpectedPath     = stfTestUtils.GetTestCaseTempFilePath($@"{inputFilename}-Expected.txt", false);
            var fileUtils            = stfTestUtils.FileUtils;

            fileUtils.CopyFile(absolutePathInput, tempInputPath);
            fileUtils.CopyFile(absolutePathExpected, tempExpectedPath);

            // generate Actual
            var actual = fileUtils.GetCleanFileContent(tempInputPath);

            File.WriteAllText(tempActualPath, actual);

            StfAssert.FilesDoNotDiffer(testStep, tempExpectedPath, tempActualPath);
        }
コード例 #6
0
        public void TestMethodAssertFilesDifferNullAndEmpty()
        {
            const string UnitTestFile1 = @"TestData\TestMethodAssertFileNotExists1.xml";

            // null and empty strings returns false
            Assert.IsFalse(StfAssert.FilesDoDiffer("filename1 null,    filename2 Null", null, null));
            Assert.IsFalse(StfAssert.FilesDoDiffer("filename1 null,    filename2 Empty", null, string.Empty));
            Assert.IsFalse(StfAssert.FilesDoDiffer("filename1 null,    filename2 notNull", null, UnitTestFile1));
            Assert.IsFalse(StfAssert.FilesDoDiffer("filename1 Empty,   filename2 Null", string.Empty, null));
            Assert.IsFalse(StfAssert.FilesDoDiffer("filename1 Empty,   filename2 Empty", string.Empty, string.Empty));
            Assert.IsFalse(StfAssert.FilesDoDiffer("filename1 Empty,   filename2 notNull", string.Empty, UnitTestFile1));
            Assert.IsFalse(StfAssert.FilesDoDiffer("filename1 notNull, filename2 Null", UnitTestFile1, null));
            Assert.IsFalse(StfAssert.FilesDoDiffer("filename1 notNull, filename2 Empty", UnitTestFile1, string.Empty));

            Assert.IsFalse(StfAssert.FilesDoNotDiffer("filename1 null,    filename2 Null", null, null));
            Assert.IsFalse(StfAssert.FilesDoNotDiffer("filename1 null,    filename2 Empty", null, string.Empty));
            Assert.IsFalse(StfAssert.FilesDoNotDiffer("filename1 null,    filename2 notNull", null, UnitTestFile1));
            Assert.IsFalse(StfAssert.FilesDoNotDiffer("filename1 Empty,   filename2 Null", string.Empty, null));
            Assert.IsFalse(StfAssert.FilesDoNotDiffer("filename1 Empty,   filename2 Empty", string.Empty, string.Empty));
            Assert.IsFalse(StfAssert.FilesDoNotDiffer("filename1 Empty,   filename2 notNull", string.Empty, UnitTestFile1));
            Assert.IsFalse(StfAssert.FilesDoNotDiffer("filename1 notNull, filename2 Null", UnitTestFile1, null));
            Assert.IsFalse(StfAssert.FilesDoNotDiffer("filename1 notNull, filename2 Empty", UnitTestFile1, string.Empty));
        }