IsTrue() 공개 정적인 메소드

public static IsTrue ( bool value, string msg ) : void
value bool
msg string
리턴 void
예제 #1
0
        public void ManyContexts()
        {
            using (var conn = Create())
            {
                var profiler = new TestProfiler2();
                conn.RegisterProfiler(profiler);

                var perThreadContexts = new List<object>();
                for (var i = 0; i < 16; i++)
                {
                    perThreadContexts.Add(new object());
                }

                var threads = new List<Thread>();

                var results = new IEnumerable<IProfiledCommand>[16];

                for (var i = 0; i < 16; i++)
                {
                    var ix = i;
                    var thread =
                        new Thread(
                            delegate()
                            {
                                var ctx = perThreadContexts[ix];
                                profiler.RegisterContext(ctx);

                                conn.BeginProfiling(ctx);
                                var db = conn.GetDatabase(ix);

                                var allTasks = new List<Task>();

                                for (var j = 0; j < 1000; j++)
                                {
                                    allTasks.Add(db.StringGetAsync("hello" + ix));
                                    allTasks.Add(db.StringSetAsync("hello" + ix, "world" + ix));
                                }

                                Task.WaitAll(allTasks.ToArray());

                                results[ix] = conn.FinishProfiling(ctx);
                            }
                        );

                    threads.Add(thread);
                }

                threads.ForEach(t => t.Start());
                threads.ForEach(t => t.Join());

                for (var i = 0; i < results.Length; i++)
                {
                    var res = results[i];
                    Assert.IsNotNull(res);

                    var numGets = res.Count(r => r.Command == "GET");
                    var numSets = res.Count(r => r.Command == "SET");

                    Assert.AreEqual(1000, numGets);
                    Assert.AreEqual(1000, numSets);
                    Assert.IsTrue(res.All(cmd => cmd.Db == i));
                }
            }
        }
 public void AddProfileButtonIsGpoEnabled_GpoSettingsIsNull_ReturnsTrue()
 {
     _gpoSettings = null;
     BuildProfilesViewModel();
     Assert.IsTrue(_profilesViewModel.AddProfileButtonIsGpoEnabled);
 }
예제 #3
0
        private TestResult VerifyDatasetCreation(Application application, Log log)
        {
            const string prefix = "Dataset information";
            var result = new TestResult();
            var assert = new Assert(result, log);
            try
            {
                var projectPage = TabProxies.GetProjectPageTabItem(application, log);
                if (projectPage == null)
                {
                    MenuProxies.CreateNewProjectViaFileNewMenuItem(application, log);
                }

                projectPage = TabProxies.GetProjectPageTabItem(application, log);
                assert.IsNotNull(projectPage, prefix + " - The project page was not opened.");

                var datasetCount = ProjectPageControlProxies.GetNumberOfDatasetsViaProjectControl(application, log);
                var datasetIds = ProjectPageControlProxies.GetDatasetIds(application, log);
                assert.AreEqual(
                    datasetIds.Count(),
                    datasetCount,
                    prefix + " - The number of datasets does not match the number of dataset IDs before creating sub-datasets.");

                ProjectPageControlProxies.CreateChildDatasetForRoot(application, log);

                datasetCount = ProjectPageControlProxies.GetNumberOfDatasetsViaProjectControl(application, log);
                datasetIds = ProjectPageControlProxies.GetDatasetIds(application, log);
                assert.AreEqual(
                    datasetIds.Count(),
                    datasetCount,
                    prefix + " - The number of datasets does not match the number of dataset IDs after creating 1 sub-dataset.");

                ProjectPageControlProxies.CreateChildDatasetForRoot(application, log);

                datasetCount = ProjectPageControlProxies.GetNumberOfDatasetsViaProjectControl(application, log);
                datasetIds = ProjectPageControlProxies.GetDatasetIds(application, log);
                assert.AreEqual(
                    datasetIds.Count(),
                    datasetCount,
                    prefix + " - The number of datasets does not match the number of dataset IDs after creating 2 sub-datasets.");

                // Undo
                MenuProxies.UndoViaEditMenu(application, log);
                ProjectPageControlProxies.WaitForDatasetCreationOrDeletion(application, log, 2);

                datasetCount = ProjectPageControlProxies.GetNumberOfDatasetsViaProjectControl(application, log);
                datasetIds = ProjectPageControlProxies.GetDatasetIds(application, log);
                assert.AreEqual(
                    datasetIds.Count(),
                    datasetCount,
                    prefix + " - The number of datasets does not match the number of dataset IDs after undoing the creation of the second dataset.");

                // Undo
                MenuProxies.UndoViaEditMenu(application, log);
                ProjectPageControlProxies.WaitForDatasetCreationOrDeletion(application, log, 1);

                datasetCount = ProjectPageControlProxies.GetNumberOfDatasetsViaProjectControl(application, log);
                datasetIds = ProjectPageControlProxies.GetDatasetIds(application, log);
                assert.AreEqual(
                    datasetIds.Count(),
                    datasetCount,
                    prefix + " - The number of datasets does not match the number of dataset IDs after undoing the creation of the first dataset.");

                // Redo
                MenuProxies.RedoViaEditMenu(application, log);
                ProjectPageControlProxies.WaitForDatasetCreationOrDeletion(application, log, 2);

                datasetCount = ProjectPageControlProxies.GetNumberOfDatasetsViaProjectControl(application, log);
                datasetIds = ProjectPageControlProxies.GetDatasetIds(application, log);
                assert.AreEqual(
                    datasetIds.Count(),
                    datasetCount,
                    prefix + " - The number of datasets does not match the number of dataset IDs after redoing the creation of the first dataset.");

                // Redo
                MenuProxies.RedoViaEditMenu(application, log);
                ProjectPageControlProxies.WaitForDatasetCreationOrDeletion(application, log, 3);

                datasetCount = ProjectPageControlProxies.GetNumberOfDatasetsViaProjectControl(application, log);
                datasetIds = ProjectPageControlProxies.GetDatasetIds(application, log);
                assert.AreEqual(
                    datasetIds.Count(),
                    datasetCount,
                    prefix + " - The number of datasets does not match the number of dataset IDs after redoing the creation of the second dataset.");

                // Delete first child
                var ids = new List<int>(datasetIds);
                ids.Sort();
                ProjectPageControlProxies.DeleteDataset(application, log, ids[1]);
                ProjectPageControlProxies.WaitForDatasetCreationOrDeletion(application, log, 2);

                datasetCount = ProjectPageControlProxies.GetNumberOfDatasetsViaProjectControl(application, log);
                datasetIds = ProjectPageControlProxies.GetDatasetIds(application, log);
                assert.AreEqual(
                    datasetIds.Count(),
                    datasetCount,
                    prefix + " - The number of datasets does not match the number of dataset IDs after the deletion of the first dataset.");
                assert.IsTrue(datasetIds.Contains(ids[2]), prefix + " - The second dataset was deleted but should not have been.");

                // Delete second child
                ProjectPageControlProxies.DeleteDataset(application, log, ids[2]);
                ProjectPageControlProxies.WaitForDatasetCreationOrDeletion(application, log, 1);

                datasetCount = ProjectPageControlProxies.GetNumberOfDatasetsViaProjectControl(application, log);
                datasetIds = ProjectPageControlProxies.GetDatasetIds(application, log);
                assert.AreEqual(
                    datasetIds.Count(),
                    datasetCount,
                    prefix + " - The number of datasets does not match the number of dataset IDs after the deletion of the second dataset.");
            }
            catch (RegressionTestFailedException e)
            {
                var message = string.Format(CultureInfo.InvariantCulture, "Failed with exception. Error: {0}", e);
                log.Error(prefix, message);
                result.AddError(prefix + " - " + message);
            }

            return result;
        }
예제 #4
0
        private TestResult VerifyActivateDataset(Application application, Log log)
        {
            const string prefix = "Dataset activation";
            var result = new TestResult();
            var assert = new Assert(result, log);
            try
            {
                // Start new project via File menu
                var projectPage = TabProxies.GetProjectPageTabItem(application, log);
                if (projectPage == null)
                {
                    MenuProxies.CreateNewProjectViaFileNewMenuItem(application, log);
                }

                projectPage = TabProxies.GetProjectPageTabItem(application, log);
                assert.IsNotNull(projectPage, prefix + " - The project page was not opened.");

                ProjectPageControlProxies.CreateChildDatasetForRoot(application, log);
                ProjectPageControlProxies.CreateChildDatasetForRoot(application, log);

                // Wait for datasets to be created
                ProjectPageControlProxies.WaitForDatasetCreationOrDeletion(application, log, 3);

                var datasetIds = ProjectPageControlProxies.GetDatasetIds(application, log);
                var ids = new List<int>(datasetIds);
                ids.Sort();

                ProjectPageControlProxies.ActivateDataset(application, log, ids[1]);

                var isDataset1Activated = ProjectPageControlProxies.IsDatasetActivated(application, log, ids[1]);
                assert.IsTrue(isDataset1Activated, prefix + " - Failed to activate the first dataset.");

                var isDataset2Activated = ProjectPageControlProxies.IsDatasetActivated(application, log, ids[2]);
                assert.IsFalse(isDataset2Activated, prefix + " - Activated the second dataset while it should not have been.");

                ProjectPageControlProxies.ActivateDataset(application, log, ids[2]);

                isDataset1Activated = ProjectPageControlProxies.IsDatasetActivated(application, log, ids[1]);
                assert.IsTrue(isDataset1Activated, prefix + " - Deactivated the first dataset when it should not have been.");

                isDataset2Activated = ProjectPageControlProxies.IsDatasetActivated(application, log, ids[2]);
                assert.IsTrue(isDataset2Activated, prefix + " - Failed to activate the second dataset.");

                /*
                // Undo
                MenuProxies.UndoViaEditMenu(application, log);

                isDataset1Activated = ProjectPageControlProxies.IsDatasetActivated(application, log, ids[1]);
                assert.IsTrue(isDataset1Activated, prefix + " - Deactivated the first dataset when it should not have been.");

                isDataset2Activated = ProjectPageControlProxies.IsDatasetActivated(application, log, ids[2]);
                assert.IsFalse(isDataset2Activated, prefix + " - Did not undo the activation state of the second dataset.");

                // Undo
                MenuProxies.UndoViaEditMenu(application, log);

                isDataset1Activated = ProjectPageControlProxies.IsDatasetActivated(application, log, ids[1]);
                assert.IsFalse(isDataset1Activated, prefix + " - Did not undo the activation state of the first dataset.");

                isDataset2Activated = ProjectPageControlProxies.IsDatasetActivated(application, log, ids[2]);
                assert.IsFalse(isDataset2Activated, prefix + " - Still did not undo the activation state of the second dataset.");

                // Redo
                MenuProxies.RedoViaEditMenu(application, log);

                isDataset1Activated = ProjectPageControlProxies.IsDatasetActivated(application, log, ids[1]);
                assert.IsTrue(isDataset1Activated, prefix + " - Did not redo the undone activation state of the first dataset.");

                isDataset2Activated = ProjectPageControlProxies.IsDatasetActivated(application, log, ids[2]);
                assert.IsFalse(isDataset2Activated, prefix + " - Redid the activation state of the second dataset when it should not have been.");

                // Redo
                MenuProxies.RedoViaEditMenu(application, log);

                isDataset1Activated = ProjectPageControlProxies.IsDatasetActivated(application, log, ids[1]);
                assert.IsTrue(isDataset1Activated, prefix + " - Changed the activation state of the first dataset when it should not have been.");

                isDataset2Activated = ProjectPageControlProxies.IsDatasetActivated(application, log, ids[2]);
                assert.IsTrue(isDataset2Activated, prefix + " - Did not redo the undone activation state of the second dataset.");
                 * */

                ProjectPageControlProxies.DeactivateDataset(application, log, ids[1]);

                isDataset1Activated = ProjectPageControlProxies.IsDatasetActivated(application, log, ids[1]);
                assert.IsFalse(isDataset1Activated, prefix + " - Failed to deactivate the first dataset.");

                isDataset2Activated = ProjectPageControlProxies.IsDatasetActivated(application, log, ids[2]);
                assert.IsTrue(isDataset2Activated, prefix + " - Deactivated the second dataset when it should not have been.");

                ProjectPageControlProxies.DeactivateDataset(application, log, ids[2]);

                isDataset1Activated = ProjectPageControlProxies.IsDatasetActivated(application, log, ids[1]);
                assert.IsFalse(isDataset1Activated, prefix + " - Failed to deactivate the first dataset.");

                isDataset2Activated = ProjectPageControlProxies.IsDatasetActivated(application, log, ids[2]);
                assert.IsFalse(isDataset2Activated, prefix + " - Failed to deactivate the second dataset.");
            }
            catch (RegressionTestFailedException e)
            {
                var message = string.Format(
                    CultureInfo.InvariantCulture,
                    "Failed with exception. Error: {0}",
                    e);
                log.Error(prefix, message);
                result.AddError(prefix + " - " + message);
            }

            return result;
        }
예제 #5
0
 public void FindingTheWordWasTest(Table hashTable)
 {
     Assert.IsTrue(hashTable.Exists("was"));
 }
예제 #6
0
 public void Test_Method_InitTeem()
 {
     bool IsTeemBeenSussesfullyCreate = stage.InitTeemForBattle();
     Assert.IsTrue(IsTeemBeenSussesfullyCreate);
 }
예제 #7
0
 public void InsertUpdateFruitReturnValue()
 {
     NintendoLand.DataFormats.FruitData fruitData = NintendoLand.DataFormats.FruitData.Load(pathToYsiExtract);
     Assert.IsTrue(fruitData.UpdateFruit(new NintendoLand.DataFormats.FruitData.Fruit(10, NintendoLand.DataFormats.FruitData.FruitType.Bananas, NintendoLand.DataFormats.FruitData.FruitType.Strawberry)));
     Assert.IsFalse(fruitData.UpdateFruit(new NintendoLand.DataFormats.FruitData.Fruit(200, NintendoLand.DataFormats.FruitData.FruitType.Bananas, NintendoLand.DataFormats.FruitData.FruitType.Strawberry)));
 }
 public void GivenISetAsEmployeeName(string employeeName)
 {
     ViewAttendanceRecordPage viewAttendanceRecordPage = new ViewAttendanceRecordPage(driver);
     Assert.IsTrue(viewAttendanceRecordPage.IsVisible, "View Attendance Record page is not visible");
     viewAttendanceRecordPage.SetEmployeeName(employeeName);
 }
예제 #9
0
 public void Versions()
 {
     Assert.IsTrue(new gs_loader_common.Base.Version("10.0.2.1").CompareTo("9.2.3.9") > 0);
     Assert.IsTrue(new gs_loader_common.Base.Version("10.0.2.1").CompareTo("11.2.3.9") < 0);
     Assert.IsTrue(new gs_loader_common.Base.Version("10.0.1.1").CompareTo("10.0.2.1") < 0);
 }
 public void HasSingletonWorks()
 {
     Assert.IsFalse(EmptySystem.HasSingleton<EcsTestData>());
     m_Manager.CreateEntity(typeof(EcsTestData));
     Assert.IsTrue(EmptySystem.HasSingleton<EcsTestData>());
 }        
예제 #11
0
파일: TaskTest.cs 프로젝트: gym2000usa/mono
		public void Delay_Simple ()
		{
			var t = Task.Delay (300);
			Assert.IsTrue (TaskStatus.WaitingForActivation == t.Status || TaskStatus.Running == t.Status, "#1");
			Assert.IsTrue (t.Wait (400), "#2");
		}
예제 #12
0
        public TestResult VerifyCloseOnProjectOpenCheckbox(Application application, Log log)
        {
            const string prefix = "Close welcome tab on project open";
            var result = new TestResult();
            var assert = new Assert(result, log);
            try
            {
                var startPage = TabProxies.GetStartPageTabItem(application, log);
                if (startPage == null)
                {
                    log.Info(prefix, "Opening start page.");
                    MenuProxies.SwitchToStartPageViaViewStartPageMenuItem(application, log);
                }

                startPage = TabProxies.GetStartPageTabItem(application, log);
                if (startPage == null)
                {
                    var message = "Failed to get the start page.";
                    log.Error(prefix, message);
                    result.AddError(prefix + " - " + message);
                    return result;
                }

                try
                {
                    if (!startPage.IsSelected)
                    {
                        log.Info(prefix, "Setting focus to start page.");
                        startPage.Select();
                    }
                }
                catch (Exception e)
                {
                    var message = string.Format(
                        CultureInfo.InvariantCulture,
                        "Failed to select the start page tab. Error was: {0}",
                        e);
                    log.Error(prefix, message);
                    result.AddError(prefix + " - " + message);

                    return result;
                }

                // Check 'keep open' flag
                WelcomePageControlProxies.UncheckCloseWelcomePageOnProjectOpen(application, log);

                // New button
                var newProjectSearchCriteria = SearchCriteria
                    .ByAutomationId(WelcomeViewAutomationIds.NewProject);
                var newProjectButton = (Button)startPage.Get(newProjectSearchCriteria);
                if (newProjectButton == null)
                {
                    var message = "Failed to get the 'New Project' button.";
                    log.Error(prefix, message);
                    result.AddError(prefix + " - " + message);
                    return result;
                }

                newProjectButton.Click();

                // Check that the start page hasn't been closed
                var currentStartPage = TabProxies.GetStartPageTabItem(application, log);
                assert.IsNotNull(currentStartPage, prefix + " - Start page does not exist after opening project");
                assert.IsFalse(currentStartPage.IsSelected, prefix + " - Start page is selected after opening project");

                var currentProjectPage = TabProxies.GetProjectPageTabItem(application, log);
                assert.IsNotNull(currentProjectPage, prefix + " - Project page does not exist after opening project");
                assert.IsTrue(currentProjectPage.IsSelected, prefix + " - Project page is not selected after opening project");

                // Check that File - close has been enabled
                var fileCloseMenu = MenuProxies.GetFileCloseMenuItem(application, log);
                assert.IsTrue(fileCloseMenu.Enabled, prefix + " - File - Close menu is not enabled");

                // HACK: It seems that the File menu stays open when we check the File - close menu item
                var fileMenu = MenuProxies.GetFileMenuItem(application, log);
                if (fileMenu == null)
                {
                    var message = "Failed to get the file menu.";
                    log.Error(prefix, message);
                    result.AddError(prefix + " - " + message);
                    return result;
                }

                if (fileMenu.IsFocussed)
                {
                    fileMenu.Click();
                }

                // Close the project via the close button on the tab page
                TabProxies.CloseProjectPageTab(application, log);

                WelcomePageControlProxies.CheckCloseWelcomePageOnProjectOpen(application, log);

                // New button
                newProjectButton.Click();

                // Check that the start page has been closed
                currentStartPage = TabProxies.GetStartPageTabItem(application, log);
                assert.IsNull(currentStartPage, prefix + " - Start page exists after opening project");

                // Close the project via the close button on the tab page
                TabProxies.CloseProjectPageTab(application, log);
                WelcomePageControlProxies.UncheckCloseWelcomePageOnProjectOpen(application, log);
            }
            catch (RegressionTestFailedException e)
            {
                var message = string.Format(
                    CultureInfo.InvariantCulture,
                    "Failed with exception. Error: {0}",
                    e);
                log.Error(prefix, message);
                result.AddError(prefix + " - " + message);
            }

            return result;
        }
예제 #13
0
        private TestResult VerifyTabBehaviour(Application application, Log log)
        {
            const string prefix = "Tabs";
            var result = new TestResult();
            var assert = new Assert(result, log);
            try
            {
                var startPage = TabProxies.GetStartPageTabItem(application, log);
                if (startPage == null)
                {
                    log.Info(prefix, "Opening start page.");
                    MenuProxies.SwitchToStartPageViaViewStartPageMenuItem(application, log);
                }

                // Make sure we don't close the welcome tab upon opening the project page
                WelcomePageControlProxies.UncheckCloseWelcomePageOnProjectOpen(application, log);

                var projectPage = TabProxies.GetProjectPageTabItem(application, log);
                if (projectPage == null)
                {
                    log.Info(prefix, "Opening project page.");
                    WelcomePageControlProxies.OpenProjectPageViaWelcomePageButton(application, log);
                }

                startPage = TabProxies.GetStartPageTabItem(application, log);
                if (startPage == null)
                {
                    var message = "Failed to open the start page.";
                    log.Error(prefix, message);
                    result.AddError(prefix + " - " + message);
                    return result;
                }

                projectPage = TabProxies.GetProjectPageTabItem(application, log);
                if (projectPage == null)
                {
                    var message = "Failed to open the project page.";
                    log.Error(prefix, message);
                    result.AddError(prefix + " - " + message);
                    return result;
                }

                try
                {
                    if (!startPage.IsSelected)
                    {
                        log.Info(prefix, "Setting focus to start page.");
                        startPage.Select();
                    }
                }
                catch (Exception e)
                {
                    var message = string.Format(
                        CultureInfo.InvariantCulture,
                        "Failed to select the start page tab. Error was: {0}",
                        e);
                    log.Error(prefix, message);
                    result.AddError(prefix + " - " + message);

                    return result;
                }

                assert.IsTrue(startPage.IsSelected, prefix + " - Start is selected");
                assert.IsFalse(projectPage.IsSelected, prefix + " - Project is not selected");

                MenuProxies.SwitchToProjectPageViaViewStartPageMenuItem(application, log);
                assert.IsFalse(startPage.IsSelected, prefix + " - Start is not selected");
                assert.IsTrue(projectPage.IsSelected, prefix + " - Project is selected");

                MenuProxies.SwitchToStartPageViaViewStartPageMenuItem(application, log);
                assert.IsTrue(startPage.IsSelected, prefix + " - Start is selected");
                assert.IsFalse(projectPage.IsSelected, prefix + " - Project is not selected");

                TabProxies.CloseProjectPageTab(application, log);
            }
            catch (RegressionTestFailedException e)
            {
                var message = string.Format(
                    CultureInfo.InvariantCulture,
                    "Failed with exception. Error: {0}",
                    e);
                log.Error(prefix, message);
                result.AddError(prefix + " - " + message);
            }

            return result;
        }
        private void ImportWizardVirtualEnvWorker(
            PythonVersion python,
            string venvModuleName,
            string expectedFile,
            bool brokenBaseInterpreter
            )
        {
            var mockService = new MockInterpreterOptionsService();

            mockService.AddProvider(new MockPythonInterpreterFactoryProvider("Test Provider",
                                                                             new MockPythonInterpreterFactory(python.Id, "Test Python", python.Configuration)
                                                                             ));

            using (var wpf = new WpfProxy()) {
                var settings   = wpf.Create(() => new ImportSettings(mockService));
                var sourcePath = TestData.GetTempPath(randomSubPath: true);
                // Create a fake set of files to import
                File.WriteAllText(Path.Combine(sourcePath, "main.py"), "");
                Directory.CreateDirectory(Path.Combine(sourcePath, "A"));
                File.WriteAllText(Path.Combine(sourcePath, "A", "__init__.py"), "");
                // Create a real virtualenv environment to import
                using (var p = ProcessOutput.RunHiddenAndCapture(python.InterpreterPath, "-m", venvModuleName, Path.Combine(sourcePath, "env"))) {
                    Console.WriteLine(p.Arguments);
                    p.Wait();
                    Console.WriteLine(string.Join(Environment.NewLine, p.StandardOutputLines.Concat(p.StandardErrorLines)));
                    Assert.AreEqual(0, p.ExitCode);
                }

                if (brokenBaseInterpreter)
                {
                    var cfgPath = Path.Combine(sourcePath, "env", "Lib", "orig-prefix.txt");
                    if (File.Exists(cfgPath))
                    {
                        File.WriteAllText(cfgPath, string.Format("C:\\{0:N}", Guid.NewGuid()));
                    }
                    else if (File.Exists((cfgPath = Path.Combine(sourcePath, "env", "pyvenv.cfg"))))
                    {
                        File.WriteAllLines(cfgPath, File.ReadAllLines(cfgPath)
                                           .Select(line => {
                            if (line.StartsWith("home = "))
                            {
                                return(string.Format("home = C:\\{0:N}", Guid.NewGuid()));
                            }
                            return(line);
                        })
                                           );
                    }
                }

                Console.WriteLine("All files:");
                foreach (var f in Directory.EnumerateFiles(sourcePath, "*", SearchOption.AllDirectories))
                {
                    Console.WriteLine(CommonUtils.GetRelativeFilePath(sourcePath, f));
                }

                Assert.IsTrue(
                    File.Exists(Path.Combine(sourcePath, "env", expectedFile)),
                    "Virtualenv was not created correctly"
                    );

                settings.SourcePath = sourcePath;

                string path = CreateRequestedProject(settings);

                Assert.AreEqual(settings.ProjectPath, path);
                var proj = XDocument.Load(path);

                // Does not include any .py files from the virtualenv
                AssertUtil.ContainsExactly(proj.Descendants(proj.GetName("Compile")).Select(x => x.Attribute("Include").Value),
                                           "main.py",
                                           "A\\__init__.py"
                                           );
                // Does not contain 'env'
                AssertUtil.ContainsExactly(proj.Descendants(proj.GetName("Folder")).Select(x => x.Attribute("Include").Value),
                                           "A"
                                           );

                var env = proj.Descendant("Interpreter");
                Assert.AreEqual("env\\", env.Attribute("Include").Value);
                Assert.AreEqual("lib\\", env.Descendant("LibraryPath").Value, true);
                if (brokenBaseInterpreter)
                {
                    Assert.AreEqual("env", env.Descendant("Description").Value);
                    Assert.AreEqual("", env.Descendant("InterpreterPath").Value);
                    Assert.AreEqual("", env.Descendant("WindowsInterpreterPath").Value);
                    Assert.AreEqual(Guid.Empty.ToString("B"), env.Descendant("BaseInterpreter").Value);
                    Assert.AreEqual("", env.Descendant("PathEnvironmentVariable").Value);
                }
                else
                {
                    Assert.AreEqual("env (Test Python)", env.Descendant("Description").Value);
                    Assert.AreEqual("scripts\\python.exe", env.Descendant("InterpreterPath").Value, true);
                    // The mock configuration uses python.exe for both paths.
                    Assert.AreEqual("scripts\\python.exe", env.Descendant("WindowsInterpreterPath").Value, true);
                    Assert.AreEqual(python.Id.ToString("B"), env.Descendant("BaseInterpreter").Value, true);
                    Assert.AreEqual("PYTHONPATH", env.Descendant("PathEnvironmentVariable").Value, true);
                }
            }
        }
 public void CreatingAWorld()
 {
     var w = new World();
     Assert.IsTrue(w.Empty);
     Assert.IsNull(w.Light);
 }
예제 #16
0
 public void IsValidRegexOk2()
 {
     Assert.IsTrue(RegexUtils.IsValidRegex(@"\d+"));
 }
 public void TheWhenAnObjectIsBetweenThePointAndTheLight()
 {
     var w = World.Default();
     var p = new Point(10, -10, 10);
     Assert.IsTrue(w.IsShadowed(p));
 }
예제 #18
0
        /// <summary>
        /// Verifies that the 'View' menu works as expected.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="log">The log object.</param>
        /// <returns>The test result for the current test case.</returns>
        public TestResult VerifyViewMenu(Application application, Log log)
        {
            const string prefix = "View menu";
            var result = new TestResult();
            var assert = new Assert(result, log);
            try
            {
                var startPage = TabProxies.GetStartPageTabItem(application, log);
                if (startPage != null)
                {
                    log.Info(prefix, "Closing start page.");
                    TabProxies.CloseStartPageTab(application, log);
                }

                // Make sure we don't close the welcome tab upon opening the project page
                WelcomePageControlProxies.UncheckCloseWelcomePageOnProjectOpen(application, log);

                var projectPage = TabProxies.GetProjectPageTabItem(application, log);
                if (projectPage != null)
                {
                    log.Info(prefix, "Closing project page.");
                    TabProxies.CloseProjectPageTab(application, log);
                }

                // Open start page via view menu
                MenuProxies.SwitchToStartPageViaViewStartPageMenuItem(application, log);

                startPage = TabProxies.GetStartPageTabItem(application, log);
                assert.IsNotNull(startPage, prefix + " - Check start page exists after clicking start page menu item");
                assert.IsTrue(startPage.IsSelected, prefix + " - Check start page is focussed after clicking start page menu item");
            }
            catch (RegressionTestFailedException e)
            {
                var message = string.Format(
                    CultureInfo.InvariantCulture,
                    "Failed with exception. Error: {0}",
                    e);
                log.Error(prefix, message);
                result.AddError(prefix + " - " + message);
            }

            return result;
        }
예제 #19
0
 public static void ShouldBeSameInstanceAs <T>(this T left, T right)
 {
     Assert.IsTrue(ReferenceEquals(left, right));
 }
예제 #20
0
 public void RemovingOneWordTest(Table hashTable)
 {
     Assert.IsTrue(hashTable.Exists("the"));
     hashTable.RemoveData("the");
     Assert.IsFalse(hashTable.Exists("the"));
 }
예제 #21
0
 public static void ShouldContain <T>(this IEnumerable <T> itemsToPeekInto, T itemToLookFor)
 {
     Assert.IsTrue(itemsToPeekInto.Contains(itemToLookFor));
 }
예제 #22
0
        public void SimpleCrudTest()
        {
            var afterInsert = false;
            var afterUpdate = false;
            var afterDelete = false;

            DataStore.AddType<TestItem>();
            DataStore.CreateOrUpdateStore();

            DataStore.AfterInsert += delegate
            {
                afterInsert = true;
            };
            DataStore.AfterUpdate += delegate
            {
                afterUpdate = true;
            };
            DataStore.AfterDelete += delegate
            {
                afterDelete = true;
            };

            var itemA = new TestItem("ItemA")
            {
                UUID = Guid.NewGuid(),
                ITest = 5,
                FTest = 3.14F,
                DBTest = 1.4D,
                DETest = 2.678M
            };

            var itemB = new TestItem("ItemB");
            var itemC = new TestItem("ItemC");

            // INSERT
            DataStore.Insert(itemA);
            Assert.IsTrue(afterInsert, "AfterInsert never fired");

            DataStore.Insert(itemB);
            DataStore.Insert(itemC);

            // COUNT
            var count = DataStore.Select<TestItem>().Count();
            Assert.AreEqual(3, count);

            // SELECT
            var items = DataStore.Select<TestItem>().GetValues();
            Assert.AreEqual(3, items.Count());

            var condition = DataStore.Condition<TestItem>("Name", itemB.Name, FilterOperator.Equals);
            var item = DataStore.Select<TestItem, TestItem>().Where(condition).GetValues().First();
            Assert.IsTrue(item.Equals(itemB));

            item = DataStore.Select<TestItem>(3);
            Assert.IsTrue(item.Equals(itemC));

            // FETCH

            // UPDATE
            itemC.Name = "NewItem";
            itemC.Address = "Changed Address";
            itemC.BigString = "little string";

            // test rollback
            DataStore.BeginTransaction();
            DataStore.Update(itemC);
            item = DataStore.Select<TestItem>(3);
            Assert.IsTrue(item.Name == itemC.Name);
            DataStore.Rollback();

            item = DataStore.Select<TestItem>(3);
            Assert.IsTrue(item.Name != itemC.Name);

            // test commit
            DataStore.BeginTransaction(IsolationLevel.Unspecified);
            DataStore.Update(itemC);
            DataStore.Commit();

            Assert.IsTrue(afterUpdate, "AfterUpdate never fired");

            condition = DataStore.Condition<TestItem>("Name", "ItemC", FilterOperator.Equals);
            item = DataStore.Select<TestItem, TestItem>().Where(condition).GetValues().FirstOrDefault();
            Assert.IsNull(item);

            condition = DataStore.Condition<TestItem>("Name", itemC.Name, FilterOperator.Equals);
            item = DataStore.Select<TestItem, TestItem>().Where(condition).GetValues().First();
            Assert.IsTrue(item.Equals(itemC));

            // DELETE
            DataStore.Delete(itemA);
            Assert.IsTrue(afterDelete, "AfterDelete never fired");

            condition = DataStore.Condition<TestItem>("Name", itemA.Name, FilterOperator.Equals);
            item = DataStore.Select<TestItem, TestItem>().Where(condition).GetValues().FirstOrDefault();
            Assert.IsNull(item);

            // COUNT
            count = DataStore.Select<TestItem>().Count();
            Assert.AreEqual(2, count);

            // this will create the table in newer versions of ORM
            DataStore.AddType<LateAddItem>();

            var newitems = DataStore.Select<LateAddItem>();
            Assert.IsNotNull(newitems);
        }
예제 #23
0
        public void VerifyEqOperator()
        {
            var assertTrueObject = new CompareResult()
            {
                Base = new FileSystemObject("TestPath")
                {
                    IsDirectory = true,
                    Size        = 700
                }
            };

            var assertFalseObject = new CompareResult()
            {
                Base = new FileSystemObject("TestPath2")
                {
                    IsDirectory = false,
                    Size        = 701
                }
            };

            var stringEquals = new Rule("String Equals Rule")
            {
                ResultType = RESULT_TYPE.FILE,
                Flag       = ANALYSIS_RESULT_TYPE.FATAL,
                Clauses    = new List <Clause>()
                {
                    new Clause("Path", OPERATION.EQ)
                    {
                        Data = new List <string>()
                        {
                            "TestPath"
                        }
                    }
                }
            };

            var boolEquals = new Rule("Bool Equals Rule")
            {
                ResultType = RESULT_TYPE.FILE,
                Flag       = ANALYSIS_RESULT_TYPE.FATAL,
                Clauses    = new List <Clause>()
                {
                    new Clause("IsDirectory", OPERATION.EQ)
                    {
                        Data = new List <string>()
                        {
                            "True"
                        }
                    }
                }
            };

            var intEquals = new Rule("Int Equals Rule")
            {
                ResultType = RESULT_TYPE.FILE,
                Flag       = ANALYSIS_RESULT_TYPE.FATAL,
                Clauses    = new List <Clause>()
                {
                    new Clause("Size", OPERATION.EQ)
                    {
                        Data = new List <string>()
                        {
                            "700"
                        }
                    }
                }
            };

            var boolAnalyzer   = GetAnalyzerForRule(boolEquals);
            var intAnalyzer    = GetAnalyzerForRule(intEquals);
            var stringAnalyzer = GetAnalyzerForRule(stringEquals);

            Assert.IsTrue(boolAnalyzer.Analyze(assertTrueObject).Any(x => x.Name == "Bool Equals Rule"));
            Assert.IsTrue(intAnalyzer.Analyze(assertTrueObject).Any(x => x.Name == "Int Equals Rule"));
            Assert.IsTrue(stringAnalyzer.Analyze(assertTrueObject).Any(x => x.Name == "String Equals Rule"));

            Assert.IsFalse(boolAnalyzer.Analyze(assertFalseObject).Any(x => x.Name == "Bool Equals Rule"));
            Assert.IsFalse(intAnalyzer.Analyze(assertFalseObject).Any(x => x.Name == "Int Equals Rule"));
            Assert.IsFalse(stringAnalyzer.Analyze(assertFalseObject).Any(x => x.Name == "String Equals Rule"));
        }
예제 #24
0
        private TestResult VerifyProjectInformation(Application application, Log log)
        {
            const string prefix = "Project information";
            var result = new TestResult();
            var assert = new Assert(result, log);
            try
            {
                // Start new project via File menu
                var projectPage = TabProxies.GetProjectPageTabItem(application, log);
                if (projectPage == null)
                {
                    MenuProxies.CreateNewProjectViaFileNewMenuItem(application, log);
                }

                projectPage = TabProxies.GetProjectPageTabItem(application, log);
                assert.IsNotNull(projectPage, prefix + " - The project page was not opened.");

                // Set a name
                var name = "Project-Test-Name";
                ProjectPageControlProxies.ProjectName(application, log, name);

                var storedName = ProjectPageControlProxies.ProjectName(application, log);
                assert.AreEqual(name, storedName, prefix + " - The written project name does not match the stored project name.");

                // Set a summary
                var summary = "Project-Test-Summary";
                ProjectPageControlProxies.ProjectSummary(application, log, summary);

                var storedSummary = ProjectPageControlProxies.ProjectSummary(application, log);
                assert.AreEqual(summary, storedSummary, prefix + " - The written project summary does not match the stored project summary.");

                // Set focus away from the text control so that the changes 'stick' by clicking somewhere, in this case the project tab item.
                projectPage.Click();

                // Undo
                MenuProxies.UndoViaEditMenu(application, log);
                storedName = ProjectPageControlProxies.ProjectName(application, log);
                assert.AreEqual(name, storedName, prefix + " - The project name change was undone too early.");

                storedSummary = ProjectPageControlProxies.ProjectSummary(application, log);
                assert.IsTrue(string.IsNullOrEmpty(storedSummary), prefix + " - The change to the project summary was not undone.");

                // Undo
                MenuProxies.UndoViaEditMenu(application, log);

                storedName = ProjectPageControlProxies.ProjectName(application, log);
                assert.IsTrue(string.IsNullOrEmpty(storedName), prefix + " - The change to the project name was not undone.");

                storedSummary = ProjectPageControlProxies.ProjectSummary(application, log);
                assert.IsTrue(string.IsNullOrEmpty(storedSummary), prefix + " - The change to the project summary was not undone.");

                // Redo
                MenuProxies.RedoViaEditMenu(application, log);
                storedName = ProjectPageControlProxies.ProjectName(application, log);
                assert.AreEqual(name, storedName, prefix + " - The change to the project name was not redone.");

                storedSummary = ProjectPageControlProxies.ProjectSummary(application, log);
                assert.IsTrue(string.IsNullOrEmpty(storedSummary), prefix + " - The change to the project summary was redone too early.");

                // Redo
                MenuProxies.RedoViaEditMenu(application, log);
                storedName = ProjectPageControlProxies.ProjectName(application, log);
                assert.AreEqual(name, storedName, prefix + " - The change to the project name was not redone.");

                storedSummary = ProjectPageControlProxies.ProjectSummary(application, log);
                assert.AreEqual(summary, storedSummary, prefix + " - The change to the project summary was not redone.");
            }
            catch (RegressionTestFailedException e)
            {
                var message = string.Format(
                    CultureInfo.InvariantCulture,
                    "Failed with exception. Error: {0}",
                    e);
                log.Error(prefix, message);
                result.AddError(prefix + " - " + message);
            }

            return result;
        }
예제 #25
0
        public void VerifyContainsAnyOperator()
        {
            var trueStringObject = new CompareResult()
            {
                Base = new FileSystemObject("ContainsStringObject")
            };

            var alsoTrueStringObject = new CompareResult()
            {
                Base = new FileSystemObject("StringObject")
            };

            var falseStringObject = new CompareResult()
            {
                Base = new FileSystemObject("NothingInCommon")
            };

            var stringContains = new Rule("String Contains Any Rule")
            {
                ResultType = RESULT_TYPE.FILE,
                Flag       = ANALYSIS_RESULT_TYPE.FATAL,
                Clauses    = new List <Clause>()
                {
                    new Clause("Path", OPERATION.CONTAINS_ANY)
                    {
                        Data = new List <string>()
                        {
                            "String",
                        }
                    }
                }
            };

            var stringAnalyzer = GetAnalyzerForRule(stringContains);

            Assert.IsTrue(stringAnalyzer.Analyze(trueStringObject).Any());
            Assert.IsTrue(stringAnalyzer.Analyze(alsoTrueStringObject).Any());
            Assert.IsFalse(stringAnalyzer.Analyze(falseStringObject).Any());

            var trueListObject = new CompareResult()
            {
                Base = new RegistryObject("ContainsListObject", Microsoft.Win32.RegistryView.Registry32)
                {
                    Subkeys = new List <string>()
                    {
                        "One",
                        "Two",
                        "Three"
                    }
                }
            };

            var alsoTrueListObject = new CompareResult()
            {
                Base = new RegistryObject("ContainsListObject", Microsoft.Win32.RegistryView.Registry32)
                {
                    Subkeys = new List <string>()
                    {
                        "One",
                        "Two",
                    }
                }
            };

            var falseListObject = new CompareResult()
            {
                Base = new RegistryObject("ContainsListObject", Microsoft.Win32.RegistryView.Registry32)
            };

            var listContains = new Rule("List Contains Any Rule")
            {
                ResultType = RESULT_TYPE.REGISTRY,
                Flag       = ANALYSIS_RESULT_TYPE.FATAL,
                Clauses    = new List <Clause>()
                {
                    new Clause("Subkeys", OPERATION.CONTAINS_ANY)
                    {
                        Data = new List <string>()
                        {
                            "One",
                            "Two",
                            "Three"
                        }
                    }
                }
            };

            var listAnalyzer = GetAnalyzerForRule(listContains);

            Assert.IsTrue(listAnalyzer.Analyze(trueListObject).Any());
            Assert.IsTrue(listAnalyzer.Analyze(alsoTrueListObject).Any());
            Assert.IsFalse(listAnalyzer.Analyze(falseListObject).Any());

            var trueStringDictObject = new CompareResult()
            {
                Base = new RegistryObject("ContainsStringDictObject", Microsoft.Win32.RegistryView.Registry32)
                {
                    Values = new Dictionary <string, string>()
                    {
                        { "One", "One" },
                        { "Two", "Two" },
                        { "Three", "Three" }
                    }
                }
            };

            var alsoTrueStringDict = new CompareResult()
            {
                Base = new RegistryObject("ContainsStringDictObject", Microsoft.Win32.RegistryView.Registry32)
                {
                    Values = new Dictionary <string, string>()
                    {
                        { "One", "One" },
                        { "Two", "Three" },
                    }
                }
            };

            var superFalseStringDictObject = new CompareResult()
            {
                Base = new RegistryObject("ContainsStringDictObject", Microsoft.Win32.RegistryView.Registry32)
                {
                    Values = new Dictionary <string, string>()
                    {
                        { "One", "Two" },
                        { "Three", "Four" },
                    }
                }
            };

            var stringDictContains = new Rule("String Dict Contains Any Rule")
            {
                ResultType = RESULT_TYPE.REGISTRY,
                Flag       = ANALYSIS_RESULT_TYPE.FATAL,
                Clauses    = new List <Clause>()
                {
                    new Clause("Values", OPERATION.CONTAINS_ANY)
                    {
                        DictData = new List <KeyValuePair <string, string> >()
                        {
                            new KeyValuePair <string, string>("One", "One"),
                            new KeyValuePair <string, string>("Two", "Two"),
                            new KeyValuePair <string, string>("Three", "Three")
                        }
                    }
                }
            };

            var stringDictAnalyzer = GetAnalyzerForRule(stringDictContains);

            Assert.IsTrue(stringDictAnalyzer.Analyze(trueStringDictObject).Any());
            Assert.IsTrue(stringDictAnalyzer.Analyze(alsoTrueStringDict).Any());
            Assert.IsFalse(stringDictAnalyzer.Analyze(superFalseStringDictObject).Any());

            var trueListDictObject = new CompareResult()
            {
                Base = new RegistryObject("ContainsListDictObject", Microsoft.Win32.RegistryView.Registry32)
                {
                    Permissions = new Dictionary <string, List <string> >()
                    {
                        {
                            "User", new List <string>()
                            {
                                "Read",
                                "Execute"
                            }
                        }
                    }
                }
            };

            var alsoTrueListDictObject = new CompareResult()
            {
                Base = new RegistryObject("ContainsListDictObject", Microsoft.Win32.RegistryView.Registry32)
                {
                    Permissions = new Dictionary <string, List <string> >()
                    {
                        {
                            "User", new List <string>()
                            {
                                "Read",
                            }
                        }
                    }
                }
            };

            var falseListDictObject = new CompareResult()
            {
                Base = new RegistryObject("ContainsListDictObject", Microsoft.Win32.RegistryView.Registry32)
                {
                    Permissions = new Dictionary <string, List <string> >()
                    {
                        {
                            "Taco", new List <string>()
                            {
                                "Read",
                                "Execute"
                            }
                        }
                    }
                }
            };

            var listDictContains = new Rule("List Dict Contains Any Rule")
            {
                ResultType = RESULT_TYPE.REGISTRY,
                Flag       = ANALYSIS_RESULT_TYPE.FATAL,
                Clauses    = new List <Clause>()
                {
                    new Clause("Permissions", OPERATION.CONTAINS_ANY)
                    {
                        DictData = new List <KeyValuePair <string, string> >()
                        {
                            new KeyValuePair <string, string>("User", "Execute"),
                            new KeyValuePair <string, string>("User", "Read")
                        }
                    }
                }
            };

            var listDictAnalyzer = GetAnalyzerForRule(listDictContains);

            Assert.IsTrue(listDictAnalyzer.Analyze(trueListDictObject).Any());
            Assert.IsTrue(listDictAnalyzer.Analyze(alsoTrueListDictObject).Any());
            Assert.IsFalse(listDictAnalyzer.Analyze(falseListDictObject).Any());
        }
예제 #26
0
    public async Task OrderingAndPaging() {
      var entityManager = await TestFns.NewEm(_serviceName);
      EntityQuery<Product> query;
      IEnumerable<Product> products;

      try {
        // Products sorted by name
        query = new EntityQuery<Product>().Expand("Category").OrderBy(p => p.ProductName);
        products = await entityManager.ExecuteQuery(query);
        VerifyProductResults(products);

        // Products sorted by name in descending order
        query = new EntityQuery<Product>().Expand("Category").OrderByDescending(p => p.ProductName);
        products = await entityManager.ExecuteQuery(query);
        VerifyProductResults(products);

        // Products sorted by price descending, then name ascending
        query = new EntityQuery<Product>().Expand("Category").OrderBy(p => p.ProductName).OrderByDescending(p => p.ProductName);
        products = await entityManager.ExecuteQuery(query);
        VerifyProductResults(products);

        // look in results for ...
        //    (27) 'Schoggi Schokolade' at $43.9 in 'Confections', 
        //    (63) 'Vegie-spread' at $43.9 in 'Condiments',...

        // Products sorted by related category descending
        query = new EntityQuery<Product>().Expand("Category").OrderByDescending(p => p.Category.CategoryName);
        products = await entityManager.ExecuteQuery(query);
        VerifyProductResults(products);

        // First 5 of products ordered by product name, then expanded to related category
        query = new EntityQuery<Product>().OrderBy(p => p.ProductName).Take(5).Expand("Category");
        products = await entityManager.ExecuteQuery(query);
        VerifyProductResults(products);

        // Skip first 10 of products ordered by product name, then expanded to related category
        query = new EntityQuery<Product>().OrderBy(p => p.ProductName).Skip(10).Expand("Category");
        products = await entityManager.ExecuteQuery(query);
        VerifyProductResults(products);

        // Products paging with skip and take
        query = new EntityQuery<Product>().OrderBy(p => p.ProductName).Skip(10).Take(5).Expand("Category");
        products = await entityManager.ExecuteQuery(query);
        VerifyProductResults(products);

        // Inline count of paged products
        var productQuery = new EntityQuery<Product>().Where(p => p.ProductName.StartsWith("C"));
        var pagedQuery = productQuery.OrderBy(p => p.ProductName).Skip(5).Take(5).InlineCount();

        // Execute in parallel and verify products received
        var productTask = entityManager.ExecuteQuery(productQuery);
        var pagedTask = entityManager.ExecuteQuery(pagedQuery);
        await Task.WhenAll(productTask, pagedTask);

        var productCount = productTask.Result.Count();
        var pageCount = pagedTask.Result.Count();
        var pagedQueryResult = pagedTask.Result as QueryResult<Product>;
        var inlineCount = pagedQueryResult.InlineCount;

        Assert.AreEqual(productCount, inlineCount, "Inline count should return item count excluding skip/take");
        Assert.IsTrue(pageCount <= productCount, "Paged query should return subset of total query");
      } catch (Exception e) {
        var message = TestFns.FormatException(e);
        Assert.Fail(message);
      }
    }
예제 #27
0
        public void VerifyIsBeforeOperator()
        {
            var trueIsBeforeObject = new CompareResult()
            {
                Base = new FileSystemObject("App.exe")
                {
                    SignatureStatus = new Signature(true)
                    {
                        SigningCertificate = new SerializableCertificate(Thumbprint: string.Empty, Subject: string.Empty, PublicKey: string.Empty, NotAfter: DateTime.Now, NotBefore: DateTime.Now, Issuer: string.Empty, SerialNumber: string.Empty, CertHashString: string.Empty, Pkcs7: string.Empty)
                    }
                }
            };

            var falseIsBeforeObject = new CompareResult()
            {
                Base = new FileSystemObject("App.exe")
                {
                    SignatureStatus = new Signature(true)
                    {
                        SigningCertificate = new SerializableCertificate(Thumbprint: string.Empty, Subject: string.Empty, PublicKey: string.Empty, NotAfter: DateTime.Now.AddYears(1), NotBefore: DateTime.Now, Issuer: string.Empty, SerialNumber: string.Empty, CertHashString: string.Empty, Pkcs7: string.Empty)
                    }
                }
            };

            var isBeforeRule = new Rule("Is Before Rule")
            {
                ResultType = RESULT_TYPE.FILE,
                Flag       = ANALYSIS_RESULT_TYPE.FATAL,
                Clauses    = new List <Clause>()
                {
                    new Clause("SignatureStatus.SigningCertificate.NotAfter", OPERATION.IS_BEFORE)
                    {
                        Data = new List <string>()
                        {
                            DateTime.Now.AddDays(1).ToString()
                        }
                    }
                }
            };

            var isBeforeAnalyzer = GetAnalyzerForRule(isBeforeRule);

            Assert.IsTrue(isBeforeAnalyzer.Analyze(trueIsBeforeObject).Any());
            Assert.IsFalse(isBeforeAnalyzer.Analyze(falseIsBeforeObject).Any());

            var isBeforeShortRule = new Rule("Is Before Short Rule")
            {
                ResultType = RESULT_TYPE.FILE,
                Flag       = ANALYSIS_RESULT_TYPE.FATAL,
                Clauses    = new List <Clause>()
                {
                    new Clause("SignatureStatus.SigningCertificate.NotAfter", OPERATION.IS_BEFORE)
                    {
                        Data = new List <string>()
                        {
                            DateTime.Now.AddDays(1).ToShortDateString()
                        }
                    }
                }
            };

            var isBeforeShortAnalyzer = GetAnalyzerForRule(isBeforeShortRule);

            Assert.IsTrue(isBeforeShortAnalyzer.Analyze(trueIsBeforeObject).Any());
            Assert.IsFalse(isBeforeShortAnalyzer.Analyze(falseIsBeforeObject).Any());
        }
예제 #28
0
        public void ReuseStorage()
        {
            const int ThreadCount = 16;

            // have to reset so other tests don't clober
            ConcurrentProfileStorageCollection.AllocationCount = 0;

            using (var conn = Create())
            {
                var profiler = new TestProfiler2();
                conn.RegisterProfiler(profiler);

                var perThreadContexts = new List<object>();
                for (var i = 0; i < 16; i++)
                {
                    perThreadContexts.Add(new object());
                }

                var threads = new List<Thread>();

                var results = new List<IEnumerable<IProfiledCommand>>[16];
                for (var i = 0; i < 16; i++)
                {
                    results[i] = new List<IEnumerable<IProfiledCommand>>();
                }

                for (var i = 0; i < ThreadCount; i++)
                {
                    var ix = i;
                    var thread =
                        new Thread(
                            delegate()
                            {
                                for (var k = 0; k < 10; k++)
                                {
                                    var ctx = perThreadContexts[ix];
                                    profiler.RegisterContext(ctx);

                                    conn.BeginProfiling(ctx);
                                    var db = conn.GetDatabase(ix);

                                    var allTasks = new List<Task>();

                                    for (var j = 0; j < 1000; j++)
                                    {
                                        allTasks.Add(db.StringGetAsync("hello" + ix));
                                        allTasks.Add(db.StringSetAsync("hello" + ix, "world" + ix));
                                    }

                                    Task.WaitAll(allTasks.ToArray());

                                    results[ix].Add(conn.FinishProfiling(ctx));
                                }
                            }
                        );

                    threads.Add(thread);
                }

                threads.ForEach(t => t.Start());
                threads.ForEach(t => t.Join());

                // only 16 allocations can ever be in flight at once
                var allocCount = ConcurrentProfileStorageCollection.AllocationCount;
                Assert.IsTrue(allocCount <= ThreadCount, allocCount.ToString());

                // correctness check for all allocations
                for (var i = 0; i < results.Length; i++)
                {
                    var resList = results[i];
                    foreach (var res in resList)
                    {
                        Assert.IsNotNull(res);

                        var numGets = res.Count(r => r.Command == "GET");
                        var numSets = res.Count(r => r.Command == "SET");

                        Assert.AreEqual(1000, numGets);
                        Assert.AreEqual(1000, numSets);
                        Assert.IsTrue(res.All(cmd => cmd.Db == i));
                    }
                }

                // no crossed streams
                var everything = results.SelectMany(r => r).ToList();
                for (var i = 0; i < everything.Count; i++)
                {
                    for (var j = 0; j < everything.Count; j++)
                    {
                        if (i == j) continue;

                        if (object.ReferenceEquals(everything[i], everything[j]))
                        {
                            Assert.Fail("Profilings were jumbled");
                        }
                    }
                }
            }
        }
예제 #29
0
        public void CheckForVictory_Positive()
        {
            string result = "++++";

            Assert.IsTrue(result.CheckForVictory(4, '+'));
        }
예제 #30
0
        public void IsValid_WhenPropertiesIsNotNull_ReturnsTrue()
        {
            // Arrange.
            decimal decimalValue = 111;
            float   floatValue   = 112;
            double  doubleValue  = 113;
            short   shortValue   = 114;
            int     intValue     = 115;
            long    longValue    = 116;
            ushort  ushortValue  = 117;
            uint    uintValue    = 118;
            ulong   ulongValue   = 119;

            var properties = new Dictionary <string, object>
            {
                { "property_1", "value1" },
                { "property_2", new ParsedSplit() },
                { "property_3", false },
                { "property_4", null },
                { "property_5", decimalValue },
                { "property_6", floatValue },
                { "property_7", doubleValue },
                { "property_8", shortValue },
                { "property_9", intValue },
                { "property_10", longValue },
                { "property_11", ushortValue },
                { "property_12", uintValue },
                { "property_13", ulongValue }
            };

            var sizeExpected = 1024L;

            foreach (var item in properties)
            {
                sizeExpected += item.Key.Length;

                if (item.Value is string)
                {
                    sizeExpected += ((string)item.Value).Length;
                }
            }

            // Act.
            var result = eventPropertiesValidator.IsValid(properties);

            // Assert.
            Assert.IsTrue(result.Success);
            Assert.IsNotNull(result.Value);

            var dicResult = (Dictionary <string, object>)result.Value;

            Assert.AreEqual("value1", dicResult["property_1"]);
            Assert.IsNull(dicResult["property_2"]);
            Assert.IsFalse((bool)dicResult["property_3"]);
            Assert.IsNull(dicResult["property_4"]);
            Assert.AreEqual(decimalValue, dicResult["property_5"]);
            Assert.AreEqual(floatValue, dicResult["property_6"]);
            Assert.AreEqual(doubleValue, dicResult["property_7"]);
            Assert.AreEqual(shortValue, dicResult["property_8"]);
            Assert.AreEqual(intValue, dicResult["property_9"]);
            Assert.AreEqual(longValue, dicResult["property_10"]);
            Assert.AreEqual(ushortValue, dicResult["property_11"]);
            Assert.AreEqual(uintValue, dicResult["property_12"]);
            Assert.AreEqual(ulongValue, dicResult["property_13"]);
            Assert.IsTrue(result.EventSize == sizeExpected);

            _log.Verify(mock => mock.Warn($"Property Splitio.Domain.ParsedSplit is of invalid type. Setting value to null"), Times.Exactly(1));
            _log.Verify(mock => mock.Warn(It.IsAny <string>()), Times.Exactly(1));
            _log.Verify(mock => mock.Error(It.IsAny <string>()), Times.Exactly(0));
        }
예제 #31
0
		public void ContainsWildcardTest() {
			Assert.IsFalse("test".ContainsWildcard());
			Assert.IsTrue("te?t".ContainsWildcard());
			Assert.IsTrue("*test".ContainsWildcard());
			Assert.IsTrue("*t*e?".ContainsWildcard());
		}
예제 #32
0
 public void IsValidRegexOk1()
 {
     Assert.IsTrue(RegexUtils.IsValidRegex(@"^(?![\s\S])"));
 }
예제 #33
0
 public void Return_True_For_16_From_27()
 {
     Assert.IsTrue(IsCaptureAllowedFrom27(1, 6));
 }
 public void GivenINavigatedToViewAttendanceRecordPage()
 {
     DashboardPage dashboardPage = new DashboardPage(driver);
     Assert.IsTrue(dashboardPage.IsVisible, "Dashboard page is not visible");
     dashboardPage.MenuComponent.OpenMenu("Time", "Attendance", "Employee Records");
 }
예제 #35
0
        public static ReplWindowProxy Prepare(
            PythonVisualStudioApp app,
            ReplWindowProxySettings settings,
            string projectName = null,
            bool useIPython    = false
            )
        {
            settings.AssertValid();

            ReplWindowProxy result = null;

            try {
                result = OpenInteractive(app, settings, projectName, useIPython ? IPythonBackend : StandardBackend);
                app    = null;

                for (int retries = 10; retries > 0; --retries)
                {
                    result.Reset();
                    result.ClearScreen();
                    result.ClearInput();

                    try {
                        var task = result.ExecuteText("print('READY')");
                        Assert.IsTrue(task.Wait(useIPython ? 30000 : 15000), "ReplWindow did not initialize in time");
                        if (!task.Result.IsSuccessful)
                        {
                            continue;
                        }
                    } catch (TaskCanceledException) {
                        continue;
                    }


                    if (useIPython)
                    {
                        // The longer we wait, the better are the chances of detecting this error
                        // This seems long enough to detect it when running locally
                        Thread.Sleep(500);

                        if (result.TextView.TextBuffer.CurrentSnapshot.Lines
                            .Any(l => l.GetText().Contains("Error using selected REPL back-end"))
                            )
                        {
                            Assert.Inconclusive("IPython is not available");
                        }

                        // In IPython mode, a help header appears at startup,
                        // but the output order is inconsistent, so we can't WaitForTextEnd
                        // (sometimes READY appears before help, sometimes after)
                        result.WaitForAnyLineContainsTextInternal("READY");
                        result.WaitForReadyForInput(TimeSpan.FromSeconds(5));
                    }
                    else
                    {
                        result.WaitForTextEnd("READY", ">");
                    }

                    result.ClearScreen();
                    return(result);
                }
                Assert.Fail("ReplWindow did not initialize");
                return(null);
            } finally {
                if (app != null)
                {
                    app.Dispose();
                }
            }
        }
 public void GivenISelectedDay(int day)
 {
     ViewAttendanceRecordPage viewAttendanceRecordPage = new ViewAttendanceRecordPage(driver);
     Assert.IsTrue(viewAttendanceRecordPage.IsVisible, "View Attendance Record page is not visible");
     viewAttendanceRecordPage.SelectDay(day);
 }
예제 #37
0
        /// <summary>
        /// Verifies that the 'File' menu works as expected.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="log">The log object.</param>
        /// <returns>The test result for the current test case.</returns>
        public TestResult VerifyFileMenu(Application application, Log log)
        {
            const string prefix = "File menu";
            var result = new TestResult();
            var assert = new Assert(result, log);
            try
            {
                var projectPage = TabProxies.GetProjectPageTabItem(application, log);
                if (projectPage != null)
                {
                    TabProxies.CloseProjectPageTab(application, log);
                }

                projectPage = TabProxies.GetProjectPageTabItem(application, log);
                assert.IsNull(projectPage, prefix + " - The project page was not closed.");

                MenuProxies.CreateNewProjectViaFileNewMenuItem(application, log);

                projectPage = TabProxies.GetProjectPageTabItem(application, log);
                assert.IsNotNull(projectPage, prefix + " - A new project was not created.");

                var fileCloseMenu = MenuProxies.GetFileCloseMenuItem(application, log);
                assert.IsTrue(fileCloseMenu.Enabled, prefix + " - File - Close menu is not enabled");

                MenuProxies.CloseProjectViaFileCloseMenuItem(application, log);

                projectPage = TabProxies.GetProjectPageTabItem(application, log);
                assert.IsNull(projectPage, prefix + " - The project page was not closed.");
            }
            catch (RegressionTestFailedException e)
            {
                var message = string.Format(
                    CultureInfo.InvariantCulture,
                    "Failed with exception. Error: {0}",
                    e);
                log.Error(prefix, message);
                result.AddError(prefix + " - " + message);
            }

            return result;
        }