/// <summary> /// The helper test Pad.... functions. /// </summary> /// <param name="source"> /// The source string /// </param> /// <param name="oldValue"> /// The old Value. /// </param> /// <param name="newValue"> /// The new Value. /// </param> /// <param name="expected"> /// The expected value of the transformed string /// </param> private void HelperTestReplace(string source, string oldValue, string newValue, string expected) { var arg = $@"""Replace"" ""{source}"" ""{oldValue}"" ""{newValue}"""; var actual = stringTransformationUtils.EvaluateFunction("STRING", arg); StfAssert.AreEqual($"Unittest Replace test actual / expected", expected, actual); }
/// <summary> /// The helper test TrimEnd.... functions. /// </summary> /// <param name="direction"> /// The direction. /// </param> /// <param name="source"> /// The source string /// </param> /// <param name="trimChars"> /// The trim Chars. /// </param> /// <param name="expected"> /// The expected value of the transformed string /// </param> private void HelperTestTrim(string direction, string source, string trimChars, string expected) { var arg = $@"""{direction}"" ""{source}"" ""{trimChars}"""; var actual = stringTransformationUtils.EvaluateFunction("STRING", arg); StfAssert.AreEqual($"Unittest TrimEnd test actual / expected", expected, actual); }
public void TestMethodGetPluginTypeTest() { // need to load the UnitTest plug-ins LoadAdditionalStfPlugins(".", "Stf.UnitTestPlugin*.dll"); var sp2 = Get <IStfUnitTestPlugin2>(); StfAssert.IsNotNull("Get<IStfUnitTestPlugin2>", sp2); StfAssert.AreEqual("sp2.StfUnitTestPlugin2Func", 102, sp2.StfUnitTestPlugin2Func()); var plugin2Type = Get <ITestPluginModel>(); StfAssert.IsNotNull("Get<ITestPluginModel>", plugin2Type); StfAssert.AreEqual("plugin2Type.TestPluginFunc", 202, plugin2Type.TestPluginFunc()); var plugin2Type2 = Get <ITestPluginModel2>(); StfAssert.IsNotNull("Get<ITestPluginModel>", plugin2Type2); StfAssert.AreEqual("plugin2Type.TestPluginFunc", "2+2=4", plugin2Type2.TestPlugin2FuncWithParams("2+2", 4)); StfAssert.AreEqual("plugin2Type.TestProp", "Default", plugin2Type2.TestProp); plugin2Type2.TestProp = "NewValue"; StfAssert.AreEqual("plugin2Type.TestProp", "NewValue", plugin2Type2.TestProp); StfAssert.AreEqual("Plugin2Func", 203, plugin2Type2.TestPlugin2Func()); }
/// <summary> /// The helper test ToUpper.... function. /// </summary> /// <param name="toCase"> /// The toCase string ToUpper or ToLower /// </param> /// <param name="source"> /// The source string /// </param> /// <param name="expected"> /// The expected string /// </param> private void HelperTestToCase(string toCase, string source, string expected) { var arg = $@"""{toCase}"" ""{source}"""; var actual = stringTransformationUtils.EvaluateFunction("STRING", arg); StfAssert.AreEqual($"Unittest {toCase} test actual / expected", expected, actual); }
public void TestDefaultGetSetConfigValues() { // Load a configuration in StfConfiguration var stfConfiguration = new StfConfiguration(@"TestData\Defaulting\DefaultSectionWithEnvironments.xml"); stfConfiguration.Environment = stfConfiguration.DefaultEnvironment; var dUsername = stfConfiguration.GetConfigValue("Users.Username"); var dPassword = stfConfiguration.GetConfigValue("Users.Password"); StfAssert.AreEqual("Default Username is User_Kasper", "User_Kasper", dUsername); StfAssert.AreEqual("Default Password is K999", "K999", dPassword); var newUserName = "******"; var newUserPassword = "******"; stfConfiguration.SetConfigValue("Users.Username", newUserName); stfConfiguration.SetConfigValue("Users.Password", newUserPassword); dUsername = stfConfiguration.GetConfigValue("Users.Username"); dPassword = stfConfiguration.GetConfigValue("Users.Password"); StfAssert.AreEqual("Default Username is updated", newUserName, dUsername); StfAssert.AreEqual("Default Password is updated", newUserPassword, dPassword); }
public void Tc013() { // Create a wrap to convert var wtId = Collection.AddWrap("Baie", "Duet", "En Bleu", 8); StfAssert.IsNotNull("Got the original wrap size 8", wtId); // Status of original wrap before var validationTarget = Get <IWtApi>(); var wrapInfo = validationTarget.WrapInfoByTrackId(wtId); var statusBefore = wrapInfo.Status; StfAssert.AreEqual("Status before deleting is 0", statusBefore, "0"); // Create two small wraps var smallWrap1 = Collection.AddWrap("Baie", "Duet", "En Bleu", 2); var smallWrap2 = Collection.AddWrap("Baie", "Duet", "En Bleu", 2); StfAssert.IsNotNull("Got one small wrap size 2", smallWrap1); StfAssert.IsNotNull("Got one more small wrap size 2", smallWrap2); // Mark the test script as InProgress StfAssert.IsNotNull("TestCase NOT finished", null); // TODO: Again we need orgWrap to be a IWrap // orgWrap.Convert(smallWrap1); // Not implemented // orgWrap.extraConvention(smallWrap2); // Not implemented }
public void Tc016() { // For now hard coded. TOdo: Random const string BrandId = "289"; const string BrandName = "Agossie"; // Use default user WrapTrackShell.Login(); StfAssert.IsNotNull("wrapTrackShell", WrapTrackShell); var randomBrand = this.GetBrand(BrandName); var newModelName = WtUtils.GetRandomString("StfModel"); var baseLineNumberOfModels = wtApi.BrandNumberOfModels(BrandId); var modelAdded = randomBrand.AddModel(newModelName); var numberOfModels = wtApi.BrandNumberOfModels(BrandId); StfAssert.IsTrue($"Model {newModelName} Added", modelAdded); StfAssert.AreEqual("Number of models for brand up by one", numberOfModels, baseLineNumberOfModels + 1); var patternDeleted = randomBrand.DeleteModel(newModelName); numberOfModels = wtApi.BrandNumberOfModels(BrandId); StfAssert.IsTrue($"Model {newModelName} Deleted", patternDeleted); StfAssert.AreEqual($"Number of models for brand as baseline", numberOfModels, baseLineNumberOfModels); }
public void TestMethodPredicate() { var peopleList = new List <People>() { new People { Name = "Name1", Age = 41, Height = 1.1 }, new People { Name = "Name2", Age = 42, Height = 1.2 }, new People { Name = "Name3", Age = 43, Height = 1.3 } }; var predicate = new Predicate(); PeopleFilter filter; List <People> result; filter = new PeopleFilter { AgeFilter = 42 }; result = predicate.FilterList(peopleList, filter); StfAssert.IsTrue("Found", result.Any()); StfAssert.AreEqual("Found", result.FirstOrDefault().Name, "Name2"); filter = new PeopleFilter { Name = "Name3" }; result = predicate.FilterList(peopleList, filter); StfAssert.IsTrue("Found", result.Any()); StfAssert.AreEqual("Found", result.FirstOrDefault().Age, 43); }
public void Tc015() { // For now hard coded. TOdo: Random const string BrandId = "289"; const string BrandName = "Agossie"; // Use default user WrapTrackShell.Login(); StfAssert.IsNotNull("wrapTrackShell", WrapTrackShell); var randomBrand = this.GetBrand(BrandName); var newPatternName = WtUtils.GetRandomString("StfPattern"); var baseLineNumberOfPatterns = wtApi.BrandNumberOfPatterns(BrandId); var patternAdded = randomBrand.AddPattern(newPatternName); var numberOfPatterns = wtApi.BrandNumberOfPatterns(BrandId); StfAssert.IsTrue($"Pattern {newPatternName} Added", patternAdded); StfAssert.GreaterThan("Number of patterns for brand up by one", numberOfPatterns, baseLineNumberOfPatterns); var patternDeleted = randomBrand.DeletePattern(newPatternName); StfAssert.IsTrue($"Pattern {newPatternName} Deleted", patternDeleted); numberOfPatterns = wtApi.BrandNumberOfPatterns(BrandId); StfAssert.AreEqual($"Number of patterns for brand as baseline", numberOfPatterns, baseLineNumberOfPatterns); }
public void TestMethodAssertInconclusive() { Assert.IsTrue(StfAssert.IsInconclusive("Check is inconclusive", "Inconclusive")); StfAssert.AreEqual("Current inconclusives", 1, StfAssert.CurrentInconclusives); StfAssert.AreEqual("Current failures", 0, StfAssert.CurrentFailures); StfAssert.AreEqual("Current passes", 2, StfAssert.CurrentPasses); }
public void Tc008() { var pathToNewImage = GetNewImagePath(); var collection = GetCurrentUserCollection(WrapTrackShell); var myWrap = collection.GetRandomWrap(); // Find number of pictures before (to wrap and to ownership) var validationTarget = Get <IWtApi>(); var wtId = myWrap.WtId; // tracking-id var beforeWrapPic = GetNumberOfPictures(validationTarget, wtId); var beforeOwnershipPic = GetNumberOfOwnershipPic(validationTarget, wtId); // Do upload myWrap.UploadWrapImage(pathToNewImage); // Find number of pictures after upload Wait(TimeSpan.FromSeconds(3)); var afterWrapPic = GetNumberOfPictures(validationTarget, wtId); var newNumWrapPic = beforeWrapPic + 1; StfAssert.AreEqual("One more picture related to wrap", newNumWrapPic, afterWrapPic); var afterOwnershipPic = GetNumberOfOwnershipPic(validationTarget, wtId); var newNumOwnershipPic = beforeOwnershipPic + 1; StfAssert.AreEqual("One more picture related to ownership", afterOwnershipPic, newNumOwnershipPic); }
/// <summary> /// The helper test file paths all steps. /// </summary> /// <param name="testCaseName"> /// The test case name. /// </param> /// <param name="testCaseId"> /// The test case id. /// </param> /// <param name="fileNameFilters"> /// The file name filters. /// </param> /// <param name="numSteps"> /// The num steps. /// </param> /// <param name="expectedFilePaths"> /// The expected file paths. /// </param> private void HelperTestFilePathsAllSteps( string testCaseName, int testCaseId, string[] fileNameFilters, int numSteps, string[,] expectedFilePaths) { StfLogger.LogHeader(testCaseName); var testCaseFileAndFolderUtils = new TestCaseFileAndFolderUtils(testCaseId, UnitTestTestDataRoot); var testCaseStepFilePathUtils = new TestCaseStepFilePathUtils( testCaseFileAndFolderUtils.TestCaseDirectory, fileNameFilters, true); for (int stepNum = 1; stepNum <= numSteps; stepNum++) { StfLogger.LogSubHeader($"Step {stepNum}"); for (var fileNameFilterNo = 0; fileNameFilterNo < fileNameFilters.Length; fileNameFilterNo++) { var actual = testCaseStepFilePathUtils.GetFileNameForStep(fileNameFilters[fileNameFilterNo], stepNum); StfAssert.AreEqual( "FileNames for step are equal", expectedFilePaths[stepNum - 1, fileNameFilterNo], actual); } } }
public void TestStfPluginLoaderRegistersSingletonCorrectly() { LoadAdditionalStfPlugins(".", "Stf.UnitTestPlugin*.dll"); var sp2 = Get <IStfUnitTestPlugin2>(); StfAssert.IsNotNull("sp2 != null", sp2); var pluginObject1 = Get <ITestPluginModel2>(); pluginObject1.TestProp = "Changed"; var pluginObject2 = Get <ITestPluginModel2>(); StfAssert.IsFalse("TestpluginModel is not a singleton", pluginObject1.Equals(pluginObject2)); StfAssert.StringEquals("Object with default value", "Default", pluginObject2.TestProp); StfAssert.StringEquals("Object with changed value", "Changed", pluginObject1.TestProp); var singletonObject = Get <IStfSingletonPluginType>(); StfAssert.IsFalse("Singleton bool is false", singletonObject.SingletonBool); StfAssert.AreEqual("SingletonInteger is 1", 1, singletonObject.SingletonInteger); singletonObject.SingletonBool = true; singletonObject.SingletonInteger++; var singletonObject2 = Get <IStfSingletonPluginType>(); StfAssert.IsTrue("Singleton object is a singleton", singletonObject2.Equals(singletonObject)); StfAssert.IsTrue("Singleton is true", singletonObject2.SingletonBool); StfAssert.AreEqual("SingletonInteger is 2", 2, singletonObject2.SingletonInteger); }
public void TestMethodParsePredicate() { var predicate = new Predicate(); var filter = predicate.ParsePredicate <PeopleFilter>("Age = 42"); StfAssert.AreEqual("Found", filter.AgeFilter, 42); }
public void TestMethodPredicatePart() { var predicate = new PredicatePart("Age = 42"); StfAssert.AreEqual("Quantifier", predicate.Quantifier, "Age"); StfAssert.AreEqual("Value", predicate.Value, "42"); StfAssert.AreEqual("PredicateExpr", predicate.PredicateExpr, "Age = 42"); }
public void TestGetTestDataValueSubStr3() { var testCaseDirectoryDataUtils = new TestCaseDirectoryDataUtils(8001, UnitTestTestDataRoot); var actual = testCaseDirectoryDataUtils.GetTestDataValue("SubStr3"); var expected = "he q"; StfAssert.AreEqual("SubStr3", expected, actual); }
public void TestGetTestDataValueCalc() { var testCaseDirectoryDataUtils = new TestCaseDirectoryDataUtils(8001, UnitTestTestDataRoot); var actual = testCaseDirectoryDataUtils.GetTestDataValue("TwoPlusOne"); var expected = "3"; StfAssert.AreEqual("Calc 2 + 1", expected, actual); }
public void TestGetTestDataValueSimple() { var testCaseDirectoryDataUtils = new TestCaseDirectoryDataUtils(8001, UnitTestTestDataRoot); var actual = testCaseDirectoryDataUtils.GetTestDataValue("FourtyTwo"); var expected = "42"; StfAssert.AreEqual("Simple FourtyTwo", expected, actual); }
/// <summary> /// The helper test case directories. /// </summary> /// <param name="actual"> /// The actual. /// </param> /// <param name="subDir"> /// The sub dir. /// </param> private void HelperTestCaseDirectories(string actual, string subDir) { var expected = subDir == null ? null : Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), UnitTestTestDataRoot, subDir)); StfAssert.AreEqual($"TestCaseDirectory correct for [{subDir}]", expected, actual); }
/// <summary> /// The helper test GUID functions. /// </summary> /// <param name="functionName"> /// The function name. /// </param> /// <param name="arg"> /// The arg. /// </param> /// <param name="expected"> /// The expected. /// </param> private void HelperTestGuid(string functionName, string arg, bool expected) { var guid = stringTransformationUtils.EvaluateFunction(functionName, arg); var formatArg = string.IsNullOrEmpty(arg) ? "D" : arg; var actual = System.Guid.TryParseExact(guid, formatArg, out _); StfAssert.AreEqual($"{functionName} - {arg}", expected, actual); }
/// <summary> /// The helper number of steps. /// </summary> /// <param name="testStep"> /// The test step. /// </param> /// <param name="testCaseId"> /// The test case id. /// </param> /// <param name="expected"> /// The expected. /// </param> private void HelperNumberOfSteps(string testStep, int testCaseId, int expected) { var testCaseFileAndFolderUtils = new TestCaseFileAndFolderUtils(testCaseId, UnitTestTestDataRoot); var templateConfigUtils = new TemplateConfigUtils(testCaseFileAndFolderUtils.TestCaseDirectory); var actual = templateConfigUtils.NumberOfSteps; StfAssert.AreEqual(testStep, expected, actual); }
public void TestBasicBrandNumberOf() { var brandNumberOfPatterns = wtApi.BrandNumberOfPatterns("34"); var brandNumberOfModels = wtApi.BrandNumberOfModels("34"); StfAssert.AreEqual("brandNumberOfPatterns", 3, brandNumberOfPatterns); StfAssert.AreEqual("brandNumberOfModels", 33, brandNumberOfModels); }
/// <summary> /// The helper_ write all text file. /// </summary> /// <param name="filename"> /// The filename. /// </param> /// <param name="testComment"> /// The test comment. /// </param> /// <param name="expected"> /// The expected. /// </param> private void HelperWriteAllTextFile(string filename, string testComment, bool expected) { var rootedFileName = Path.IsPathRooted(filename) ? filename : StfTestUtils.GetTestCaseRootFilePath(filename, false); var actual = StfTestUtils.FileUtils.WriteAllTextFile(rootedFileName, testComment); StfAssert.AreEqual(testComment, expected, actual); }
public void TestTestCaseDirectoryExists() { var testCaseFileAndFolderUtils = new TestCaseFileAndFolderUtils(9001, UnitTestTestDataRoot); var actual = testCaseFileAndFolderUtils.TestCaseDirectory; var expected = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), UnitTestTestDataRoot, "Tc9001")); StfAssert.AreEqual("TestCaseDirectory exists", expected, actual); StfAssert.AreEqual("TestCaseID", 9001, testCaseFileAndFolderUtils.TestCaseId); }
public void TestGetToWrap() { wrapTrackShell.Login(); var goneToWrap = wrapTrackShell.GetToWrap("xoxxp5f"); var wtWrapId = goneToWrap.WtId; StfAssert.AreEqual("Gone to the right Wrap", wtWrapId, "xoxxp5f"); }
/// <summary> /// The helper number of steps. /// </summary> /// <param name="testStep"> /// The test step. /// </param> /// <param name="testCaseId"> /// The test case id. /// </param> /// <param name="expected"> /// The expected. /// </param> private void HelperNumberOfSteps(string testStep, int testCaseId, int expected) { var testCaseFileAndFolderUtils = new TestCaseFileAndFolderUtils(testCaseId, UnitTestTestDataRoot); var fileNameFilters = new[] { "Template.txt", "Config.txt" }; var testCaseStepFilePathUtils = new TestCaseStepFilePathUtils(testCaseFileAndFolderUtils.TestCaseDirectory, fileNameFilters); var actual = testCaseStepFilePathUtils.NumberOfSteps; StfAssert.AreEqual(testStep, expected, actual); }
/// <summary> /// The helper stf test Utilities. /// </summary> /// <param name="testStepDescription"> /// The testStepDescription. /// </param> /// <param name="testCaseId"> /// The test Case Id. /// </param> /// <param name="expected"> /// The expected. /// </param> private void HelperStfTestUtils(string testStepDescription, int testCaseId, int expected) { var stfTestUtils = new StfTestUtils(testCaseId); var newRootFolderPath = stfTestUtils.TestCaseDirectory; var stfTestUtils2 = new StfTestUtils(testCaseId, newRootFolderPath); var actual = stfTestUtils2.GetTestCaseFolderPathsFromCache(); StfAssert.AreEqual(testStepDescription, expected, actual.Length); }
public void TestStfIgnoreDataDrivenNoStfIgnore() { if (StfIgnoreRow) { StfAssert.IsTrue("Must be false", false); return; } StfAssert.AreEqual("StfRowNowIgnored", DataRowColumnValue("Bob"), 42); }
public void TestStfIgnoreDataDrivenWithStfIgnore() { if (StfIgnoreRow) { StfAssert.AreEqual("StfRowNowIgnored", DataRowColumnValue("Bob"), 21); return; } StfAssert.AreEqual("StfRowNowIgnored", DataRowColumnValue("Bob"), 42); }
/// <summary> /// The validate wrap 13639. /// </summary> /// <param name="wrapInfo"> /// The wrap info. /// </param> private void ValidateWrap13639(WrapInfo wrapInfo) { StfAssert.AreEqual("OwnerId", "1603", wrapInfo.OwnerId); StfAssert.AreEqual("OwnerName", "Beinta.klein", wrapInfo.OwnerName); StfAssert.AreEqual("NumOfOwnershipPic", 0, wrapInfo.NumOfOwnershipPic); StfAssert.AreEqual("NumOfPictures", 0, wrapInfo.NumOfPictures); StfAssert.AreEqual("OwnershipNumber", "1", wrapInfo.OwnershipNumber); StfAssert.AreEqual("Size", "13639", wrapInfo.Size); StfAssert.AreEqual("Status", "0", wrapInfo.Status); }