public void TestCreatingTestSuiteForTestCase()
        {
            var suite = new TestSuite();
            suite.CreateTestSuiteFor(typeof(DummyTestCase));

            Assert.AreEqual(2, suite.Tests.Count);
        }
	public static TestSuite Suite()
			{
				TestSuite suite = new TestSuite("Security Tests");
				suite.AddTests(typeof(TestSecurityExceptions));
				suite.AddTests(typeof(TestSecurityElement));
				return suite;
			}
Example #3
0
        /// <summary>
        /// Gets the command to be executed before any of
        /// the child tests are run.
        /// </summary>
        /// <returns>A TestCommand</returns>
        public static TestCommand MakeOneTimeSetUpCommand(TestSuite suite, List<SetUpTearDownItem> setUpTearDown, List<TestActionItem> actions)
        {
            // Handle skipped tests
            if (suite.RunState != RunState.Runnable && suite.RunState != RunState.Explicit)
                return MakeSkipCommand(suite);

            // Build the OneTimeSetUpCommand itself
            TestCommand command = new OneTimeSetUpCommand(suite, setUpTearDown, actions);

            // Prefix with any IApplyToContext items from attributes
            if (suite.TypeInfo != null)
            {
                IApplyToContext[] changes = suite.TypeInfo.GetCustomAttributes<IApplyToContext>(true);
                if (changes.Length > 0)
                    command = new ApplyChangesToContextCommand(command, changes);
            }
            if (suite.Method!=null)
            {
                IApplyToContext[] changes = suite.Method.GetCustomAttributes<IApplyToContext>(true);
                if (changes.Length > 0)
                    command = new ApplyChangesToContextCommand(command, changes);
            }

            return command;
        }
		public async Task TearDown (TestSuite suite)
		{
			if (!Persistent)
				await Server.Stop ();
			foreach (var extension in HttpClientTestFramework.Extensions)
				await extension.TearDown (suite);
		}
Example #5
0
        public static TestSuite suite()
        {
            TestSuite suite = new TestSuite();
            suite.AddTestSuite(typeof(IdentityTest));
            suite.AddTestSuite(typeof(AllTest));
            suite.AddTestSuite(typeof(FailTest));
            suite.AddTestSuite(typeof(OneTest));
            suite.AddTestSuite(typeof(FailAtNodesTest));
            suite.AddTestSuite(typeof(SomeTest));
            suite.AddTestSuite(typeof(TopDownUntilTest));
            suite.AddTestSuite(typeof(SpineBottomUpTest));
            suite.AddTestSuite(typeof(SpineTopDownTest));
            suite.AddTestSuite(typeof(SuccessCounterTest));
            suite.AddTestSuite(typeof(IfThenElseTest));
            suite.AddTestSuite(typeof(AllSpinesBottomUpTest));
            suite.AddTestSuite(typeof(ChildTest));
            suite.AddTestSuite(typeof(CollectTest));
            suite.AddTestSuite(typeof(DescendantTest));
            suite.AddTestSuite(typeof(DoWhileSuccessTest));
            suite.AddTestSuite(typeof(LoggerTest));
            suite.AddTestSuite(typeof(NestingDepthTest));
            suite.AddTestSuite(typeof(OnceTopDownTest));
            suite.AddTestSuite(typeof(TimeLogVisitorTest));
            suite.AddTestSuite(typeof(LibraryTest));

            return suite;
        }
Example #6
0
        private static void BenchmarkStringJoin(string[] testData, string expectedData)
        {
            var testName = String.Format("Joining strings - with {0} string", testData.Length);

            // Create a TestSuite class for a group of BenchmarTests
            var benchmarkSuite = new TestSuite<string[], string>(testName)
                                    // You don't have to specify a method group - but you'll probably want to give an explicit name if you use
                                    .Plus(input => String.Join(" ", input), "String.Join")
                                    .Plus(LoopingWithStringBuilderCommumUsage)
                                    .Plus(input => LoopingWithStringBuilderWithInitialCapacity(input, expectedData.Length + 2), "LoopingWithStringBuilderWithInitialCapacity")
                                    .Plus(LoopingWithStringBuilderWithInitialValue)
                                    .Plus(input => LoopingWithStringBuilderWithInitialValueAndCapacity(input, expectedData.Length + 2), "LoopingWithStringBuilderWithInitialValueAndCapacity")
                                    .Plus(LoopingWithStringConcatenation)
                                    .Plus(LoopingWithStringConcat)
                                    .Plus(LoopingWithStringFormat);

            // This returns a ResultSuite
            var resultsSmallData = benchmarkSuite.RunTests(testData, expectedData)
                                        // Again, scaling returns a new ResultSuite, with all the results scaled
                                        // - in this case they'll all have the same number of iterations
                                        .ScaleByBest(ScalingMode.VaryDuration);

            // There are pairs for name and score, iterations or duration - but we want name, duration *and* score
            resultsSmallData.Display(ResultColumns.NameAndDuration | ResultColumns.Score,
                                        // Scale the scores to make the best one get 1.0
                                        resultsSmallData.FindBest());
        }
	public static TestSuite Suite()
			{
				TestSuite suite = new TestSuite("Collection Tests");
				suite.AddTests(typeof(TestArrayList));
				suite.AddTests(typeof(TestHashTable));
				return suite;
			}
 /// <summary>
 /// Construct a OneTimeTearDownCommand
 /// </summary>
 /// <param name="suite">The test suite to which the command applies</param>
 /// <param name="setUpTearDown">A SetUpTearDownList for use by the command</param>
 public OneTimeTearDownCommand(TestSuite suite, SetUpTearDownList setUpTearDown)
     : base(suite)
 {
     if (suite.FixtureType != null)
         _tearDownMethods = Reflect.GetMethodsWithAttribute(suite.FixtureType, typeof(OneTimeTearDownAttribute), true);
     _setUpTearDown = setUpTearDown;
 }
Example #9
0
        public void AssertTestCase_TestCaseError_StackTraceIsFilledWithXml()
        {
            var sut = "not empty string";
            var ctrStub = new Mock<Constraint>();
            ctrStub.Setup(c => c.Matches(It.IsAny<object>())).Throws(new ExternalDependencyNotFoundException("Filename"));
            var ctr = ctrStub.Object;

            var xmlContent = "<test><system></system><assert></assert></test>";

            var testSuite = new TestSuite();

            try
            {
                testSuite.AssertTestCase(sut, ctr, xmlContent);
            }
            catch (CustomStackTraceErrorException ex)
            {
                Assert.That(ex.StackTrace, Is.EqualTo(xmlContent));
            }
            catch (Exception ex)
            {
                if (ex.InnerException==null)
                    Assert.Fail("The exception should have been an CustomStackTraceErrorException but was {0}.\r\n{1}", new object[] { ex.GetType().FullName, ex.StackTrace });
                else
                    Assert.Fail("The exception should have been an CustomStackTraceErrorException but was something else. The inner exception is {0}.\r\n{1}", new object[] { ex.InnerException.GetType().FullName, ex.InnerException.StackTrace });
            }
        }
 public void TestFailsWhenDerivedExceptionIsThrown()
 {
     TestSuite suite = new TestSuite(typeof(DerivedExceptionThrownClass));
     TestResult result = (TestResult)suite.Run().Results[0];
     Assert.That(result.ResultState, Is.EqualTo(ResultState.Failure));
     Assert.That(result.Message, Is.EqualTo("Expected Exception of type <System.Exception>, but was <System.ApplicationException>"));
 }
 public virtual void Visit(TestSuite testSuite)
 {
     foreach (TestUnit child in testSuite.Children)
     {
         child.Apply(this);
     }
 }
Example #12
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			test_suite = Intent.GetStringExtra ("TestSuite");
			suite = AndroidRunner.Suites [test_suite];

			var menu = new RootElement (String.Empty);
			
			main = new Section (test_suite);
			foreach (ITest test in suite.Tests) {
				TestSuite ts = test as TestSuite;
				if (ts != null)
					main.Add (new TestSuiteElement (ts));
				else
					main.Add (new TestCaseElement (test as NUnit.Framework.Internal.Test));
			}
			menu.Add (main);

			Section options = new Section () {
				new ActionElement ("Run all", Run),
			};
			menu.Add (options);

			var da = new DialogAdapter (this, menu);
			var lv = new ListView (this) {
				Adapter = da
			};
			SetContentView (lv);
		}
    /**
     * Initialize class resources.
     */
    void Start()
    {
        // Create test suite
        TestSuite suite = new TestSuite();

        // For each assembly in this app domain
        foreach (Assembly assem in AppDomain.CurrentDomain.GetAssemblies())
        {
            // For each type in the assembly
            foreach (Type type in assem.GetTypes())
            {
                // If this is a valid test case
                // i.e. derived from TestCase and instantiable
                if (typeof(TestCase).IsAssignableFrom(type) &&
                    type != typeof(TestCase) &&
                    !type.IsAbstract)
                {
                    // Add tests to suite
                    suite.AddAll(type.GetConstructor(new Type[0]).Invoke(new object[0]) as TestCase);
                }
            }
        }

        // Run the tests
        TestResult res = suite.Run(null);

        // Report results
        Unity3D_TestReporter reporter = new Unity3D_TestReporter();
        reporter.LogResults(res);
    }
Example #14
0
        /// <summary>
        /// Gets the command to be executed before any of
        /// the child tests are run.
        /// </summary>
        /// <returns>A TestCommand</returns>
        public static TestCommand MakeOneTimeSetUpCommand(TestSuite suite, List<SetUpTearDownItem> setUpTearDown, List<TestActionItem> actions)
        {
            // Handle skipped tests
            if (suite.RunState != RunState.Runnable && suite.RunState != RunState.Explicit)
                return MakeSkipCommand(suite);

            // Build the OneTimeSetUpCommand itself
            TestCommand command = new OneTimeSetUpCommand(suite, setUpTearDown, actions);

            // Prefix with any IApplyToContext items from attributes
            IList<IApplyToContext> changes = null;

            if (suite.TypeInfo != null)
                changes = suite.TypeInfo.GetCustomAttributes<IApplyToContext>(true);
            else if (suite.Method != null)
                changes = suite.Method.GetCustomAttributes<IApplyToContext>(true);
            else
            {
                var testAssembly = suite as TestAssembly;
                if (testAssembly != null)
#if PORTABLE
                    changes = new List<IApplyToContext>(testAssembly.Assembly.GetAttributes<IApplyToContext>());
#else
                    changes = (IApplyToContext[])testAssembly.Assembly.GetCustomAttributes(typeof(IApplyToContext), true);
#endif
            }

            if (changes != null && changes.Count > 0)
                command = new ApplyChangesToContextCommand(command, changes);

            return command;
        }
		public TestSuiteElement (TestSuite suite, AndroidRunner runner) : base (suite, runner)
		{
			if (Suite.TestCaseCount > 0)
				Indicator = ">"; // hint there's more

            Caption = suite.FullName;
		}
Example #16
0
		void Build (TestSuite suite)
		{
//			if (Environment.GetEnvironmentVariables().Contains("START_DEBUG"))
//				System.Diagnostics.Debugger.Launch ();
			ReadLists ();
			XmlDocument whole = new XmlDocument ();
			whole.Load (@"testsuite/TESTS/catalog-fixed.xml");

			foreach (XmlElement testCase in whole.SelectNodes ("test-suite/test-catalog/test-case")) {
				string testid = testCase.GetAttribute ("id");

				if (skipTargets.Contains (testid))
					continue;

				CatalogTestCase ctc = new CatalogTestCase(EnvOptions.OutputDir, testCase);
				if (!ctc.Process ())
					continue;

				SingleTestTransform stt = new SingleTestTransform (ctc);

				string expectedException = (string) expectedExceptions[testid];
				bool isKnownFailure = knownFailures.Contains (testid) || fixmeList.Contains (testid);

				suite.Add (new TestFromCatalog (testid, stt, expectedException,
					EnvOptions.InverseResults, isKnownFailure));
			}
		}
Example #17
0
        public void AssertTestCase_TestCaseError_MessageIsAvailable()
        {
            var sut = "not empty string";
            var ctrStub = new Mock<Constraint>();
            ctrStub.Setup(c => c.Matches(It.IsAny<object>())).Throws(new ExternalDependencyNotFoundException("Filename"));
            var ctr = ctrStub.Object;

            var xmlContent = "<test><system></system><assert></assert></test>";

            var testSuite = new TestSuite();

            try
            {
                testSuite.AssertTestCase(sut, ctr, xmlContent);
            }
            catch (CustomStackTraceErrorException ex)
            {
                Console.WriteLine(ex.Message);
                Assert.That(ex.Message, Is.StringContaining("Filename"));
            }
            catch (Exception ex)
            {
                Assert.Fail("The exception should have been a CustomStackTraceErrorException but was {0}.", new object[] { ex.GetType().FullName });
            }
        }
        public void AddChildToTestCase()
        {
            TestSuite master = new TestSuite("master", null);
            TestCase test = new TestCase("test", master);

            test.AddChild(new TestCase());
        }
	public static TestSuite Suite()
			{
				TestSuite suite = new TestSuite("Core Class Tests");
#if CONFIG_FRAMEWORK_2_0	
				suite.AddTests(typeof(TestActivationArguments));
				suite.AddTests(typeof(TestActivationContext));
				suite.AddTests(typeof(TestApplicationId));
				suite.AddTests(typeof(TestApplicationIdentity));
#endif
				suite.AddTests(typeof(TestArgIterator));
				suite.AddTests(typeof(TestArray));
				suite.AddTests(typeof(TestAttribute));
				suite.AddTests(typeof(TestBoolean));
				suite.AddTests(typeof(TestConvert));
				suite.AddTests(typeof(TestDecimal));
				suite.AddTests(typeof(TestDelegate));
				suite.AddTests(typeof(TestDouble));
				suite.AddTests(typeof(TestSByte));
				suite.AddTests(typeof(TestString));
			#if !ECMA_COMPAT
				suite.AddTests(typeof(TestGuid));
			#endif
				suite.AddTests(typeof(TestSystemExceptions));
				suite.AddTests(typeof(TestVersion));
				return suite;
			}
 /// <summary>
 /// Constructs a OneTimeSetUpComand for a suite
 /// </summary>
 /// <param name="suite">The suite to which the command applies</param>
 public OneTimeSetUpCommand(TestSuite suite)
     : base(suite)
 {
     this.suite = suite;
     this.fixtureType = suite.FixtureType;
     this.arguments = suite.arguments;
 }
Example #21
0
		public static TestSuite suite()
		{
			TestSuite suite = new TestSuite("IO tests");

			suite.Add(new CipherStreamTest());

			return suite;
		}
 public void testInvalidConstructorGivesErrorMessage()
 {
     TestSuite suite = new TestSuite(typeof(ClassWithNoValidConstructor));
     Assert.That(suite.TestCaseCount, Is.EqualTo(1), null);
     TestResult result = suite.Run();
     Assert.That(result.ResultState, Is.EqualTo(ResultState.Failure ), null);
     Assert.That(((TestResult)result.Results[0]).Message, Contains.Substring("no default constructor"));
 }
	public static TestSuite Suite()
			{
				TestSuite suite = new TestSuite("System.Reflection tests");
			#if !ECMA_COMPAT
				suite.AddTests(typeof(TestInvoke));
			#endif
				return suite;
			}
Example #24
0
		public static TestSuite suite()
		{
			TestSuite suite = new TestSuite("OCSP Tests");

			suite.Add(new OcspTest());

			return suite;
		}
Example #25
0
        public static TestSuite suite()
        {
			TestSuite suite = new TestSuite("EC Math tests");

			suite.Add(new ECPointTest());

			return suite;
        }
Example #26
0
        public void SetUp()
        {
            _test = new TestMethod(new MethodWrapper(typeof(DummySuite), "DummyMethod"));
            _testResult = _test.MakeTestResult();

            _suite = new TestSuite(typeof(DummySuite));
            _suiteResult = (TestSuiteResult)_suite.MakeTestResult();
        }
	public static TestSuite Suite()
			{
				TestSuite suite = new TestSuite("InteropServices Tests");
				suite.AddTests(typeof(TestInteropServices));
				suite.AddTests(typeof(TestGCHandle));
				suite.AddTests(typeof(TestMarshal));
				return suite;
			}
Example #28
0
        public static TestSuite suite()
        {
            TestSuite suite = new TestSuite("Math tests");

            suite.Add(new BigIntegerTest());

            return suite;
        }
Example #29
0
        public static Test MustFind(string name, TestSuite suite, bool recursive)
        {
            Test test = Find(name, suite, recursive);

            Assert.NotNull(test, "Unable to find test {0}", name);

            return test;
        }
	public static TestSuite Suite()
			{
				TestSuite suite = new TestSuite("Reflection.Emit tests");
			#if !ECMA_COMPAT
				suite.AddTests(typeof(TestEmit));
			#endif
				return suite;
			}
        public TestSuite RunTestsOnArchive(TestSession testSession)
        {
            AddmlDefinition addmlDefinition = testSession.AddmlDefinition;

            _addmlProcessRunner.Init(addmlDefinition);

            List <FlatFile> flatFiles = addmlDefinition.GetFlatFiles();

            foreach (FlatFile file in flatFiles)
            {
                string testName = string.Format(Messages.RunningAddmlProcessesOnFile, file.GetName());

                var recordIdx = 0;

                _statusEventHandler.RaiseEventFileProcessingStarted(
                    new FileProcessingStatusEventArgs(testName, file.GetName())
                    );

                _addmlProcessRunner.RunProcesses(file);

                IRecordEnumerator recordEnumerator =
                    _flatFileReaderFactory.GetRecordEnumerator(testSession.Archive, file);

                int numberOfRecordsWithFieldDelimiterError = 0;

                while (recordEnumerator != null && recordEnumerator.MoveNext())
                {
                    try
                    {
                        _statusEventHandler.RaiseEventRecordProcessingStart();
                        Record record = recordEnumerator.Current;
                        _addmlProcessRunner.RunProcesses(file, record);

                        foreach (Field field in record.Fields)
                        {
                            _addmlProcessRunner.RunProcesses(file, field);
                        }
                    }
                    catch (ArkadeAddmlDelimiterException exception)
                    {
                        numberOfRecordsWithFieldDelimiterError++;

                        if (numberOfRecordsWithFieldDelimiterError <= MaxNumberOfSingleReportedFieldDelimiterErrors)
                        {
                            _testResultsFailedRecordsList.Add(new TestResult(ResultType.Error,
                                                                             new AddmlLocation(file.GetName(), exception.RecordName, ""),
                                                                             exception.Message + " Felttekst: " + exception.RecordData)
                                                              );

                            _statusEventHandler.RaiseEventOperationMessage(
                                $"{AddmlMessages.RecordLengthErrorTestName} i fil {file.GetName()}, post nummer {recordIdx}, feil nummer {numberOfRecordsWithFieldDelimiterError}",
                                exception.Message + " Felttekst: " + exception.RecordData, OperationMessageStatus.Error
                                );
                        }
                        else
                        {
                            _statusEventHandler.RaiseEventOperationMessage(
                                $"ADDML-poster med feil antall felt i filen {file.GetName()}",
                                $"Totalt antall: {numberOfRecordsWithFieldDelimiterError}",
                                OperationMessageStatus.Error
                                );
                        }
                    }
                    finally
                    {
                        _statusEventHandler.RaiseEventRecordProcessingStopped();
                    }

                    recordIdx++;
                }

                if (numberOfRecordsWithFieldDelimiterError > 0)
                {
                    _testResultsFailedRecordsList.Add(new TestResult(ResultType.ErrorGroup, new Location(file.GetName()),
                                                                     $"Filens totale antall poster med feil antall felt: {numberOfRecordsWithFieldDelimiterError}",
                                                                     numberOfRecordsWithFieldDelimiterError)
                                                      );
                }

                _addmlProcessRunner.EndOfFile(file);

                _statusEventHandler.RaiseEventFileProcessingFinished(
                    new FileProcessingStatusEventArgs(testName, file.GetName(), true)
                    );
            }

            TestSuite testSuite = _addmlProcessRunner.GetTestSuite();

            testSuite.AddTestRun(new ControlExtraOrMissingFiles(addmlDefinition, testSession.Archive).GetTestRun());
            testSuite.AddTestRun(new ControlRecordAndFieldDelimiters(_testResultsFailedRecordsList).GetTestRun());

            return(testSuite);
        }
 /// <summary>
 /// Method to create a test case from a MethodInfo and add
 /// it to the fixture being built. It first checks to see if
 /// any global TestCaseBuilder addin wants to build the
 /// test case. If not, it uses the internal builder
 /// collection maintained by this fixture builder.
 ///
 /// The default implementation has no test case builders.
 /// Derived classes should add builders to the collection
 /// in their constructor.
 /// </summary>
 /// <param name="method">The method for which a test is to be created</param>
 /// <param name="suite">The test suite being built.</param>
 /// <returns>A newly constructed Test</returns>
 private Test BuildTestCase(IMethodInfo method, TestSuite suite)
 {
     return(_testBuilder.CanBuildFrom(method, suite)
         ? _testBuilder.BuildFrom(method, suite)
         : null);
 }
Example #33
0
        public Report Parse(string resultsFile)
        {
            _resultsFile = resultsFile;

            var doc = XDocument.Load(resultsFile);

            if (doc.Root == null)
            {
                throw new NullReferenceException();
            }

            var report = new Report
            {
                FileName     = Path.GetFileNameWithoutExtension(resultsFile),
                AssemblyName = doc.Root.Attribute("name") != null?doc.Root.Attribute("name").Value : null,
                TestRunner   = TestRunner.NUnit
            };


            // run-info & environment values -> RunInfo
            var runInfo = CreateRunInfo(doc, report);

            if (runInfo != null)
            {
                report.AddRunInfo(runInfo.Info);
            }

            // report counts
            report.Total = doc.Descendants("test-case").Count();

            report.Passed =
                doc.Root.Attribute("passed") != null
                    ? Int32.Parse(doc.Root.Attribute("passed").Value)
                    : doc.Descendants("test-case").Where(x => x.Attribute("result").Value.Equals("success", StringComparison.CurrentCultureIgnoreCase)).Count();

            report.Failed =
                doc.Root.Attribute("failed") != null
                    ? Int32.Parse(doc.Root.Attribute("failed").Value)
                    : Int32.Parse(doc.Root.Attribute("failures").Value);

            report.Errors =
                doc.Root.Attribute("errors") != null
                    ? Int32.Parse(doc.Root.Attribute("errors").Value)
                    : 0;

            report.Inconclusive =
                doc.Root.Attribute("inconclusive") != null
                    ? Int32.Parse(doc.Root.Attribute("inconclusive").Value)
                    : Int32.Parse(doc.Root.Attribute("inconclusive").Value);

            report.Skipped =
                doc.Root.Attribute("skipped") != null
                    ? Int32.Parse(doc.Root.Attribute("skipped").Value)
                    : Int32.Parse(doc.Root.Attribute("skipped").Value);

            report.Skipped +=
                doc.Root.Attribute("ignored") != null
                    ? Int32.Parse(doc.Root.Attribute("ignored").Value)
                    : 0;

            // report duration
            report.StartTime =
                doc.Root.Attribute("start-time") != null
                    ? doc.Root.Attribute("start-time").Value
                    : doc.Root.Attribute("date").Value + " " + doc.Root.Attribute("time").Value;

            report.EndTime =
                doc.Root.Attribute("end-time") != null
                    ? doc.Root.Attribute("end-time").Value
                    : "";

            // report status messages
            var testSuiteTypeAssembly = doc.Descendants("test-suite")
                                        .Where(x => x.Attribute("result").Value.Equals("Failed") && x.Attribute("type").Value.Equals("Assembly"));

            report.StatusMessage = testSuiteTypeAssembly != null && testSuiteTypeAssembly.Count() > 0
                ? testSuiteTypeAssembly.First().Value
                : "";

            var suites = doc
                         .Descendants("test-suite")
                         .Where(x => x.Attribute("type").Value.Equals("TestFixture", StringComparison.CurrentCultureIgnoreCase));

            suites.AsParallel().ToList().ForEach(ts =>
            {
                var testSuite  = new TestSuite();
                testSuite.Name = ts.Attribute("name").Value;

                // Suite Time Info
                testSuite.StartTime =
                    ts.Attribute("start-time") != null
                        ? ts.Attribute("start-time").Value
                        : string.Empty;

                testSuite.StartTime =
                    String.IsNullOrEmpty(testSuite.StartTime) && ts.Attribute("time") != null
                        ? ts.Attribute("time").Value
                        : testSuite.StartTime;

                testSuite.EndTime =
                    ts.Attribute("end-time") != null
                        ? ts.Attribute("end-time").Value
                        : "";

                // any error messages and/or stack-trace
                var failure = ts.Element("failure");
                if (failure != null)
                {
                    var message = failure.Element("message");
                    if (message != null)
                    {
                        testSuite.StatusMessage = message.Value;
                    }

                    var stackTrace = failure.Element("stack-trace");
                    if (stackTrace != null && !string.IsNullOrWhiteSpace(stackTrace.Value))
                    {
                        testSuite.StatusMessage = string.Format(
                            "{0}\n\nStack trace:\n{1}", testSuite.StatusMessage, stackTrace.Value);
                    }
                }

                var output = ts.Element("output") != null?ts.Element("output").Value:null;
                if (!string.IsNullOrWhiteSpace(output))
                {
                    testSuite.StatusMessage += "\n\nOutput:\n" + output;
                }

                // get test suite level categories
                var suiteCategories = this.GetCategories(ts, false);

                // Test Cases
                ts.Descendants("test-case").AsParallel().ToList().ForEach(tc =>
                {
                    var test = new Model.Test();

                    test.Name   = tc.Attribute("name").Value;
                    test.Status = StatusExtensions.ToStatus(tc.Attribute("result").Value);

                    // main a master list of all status
                    // used to build the status filter in the view
                    report.StatusList.Add(test.Status);

                    // TestCase Time Info
                    test.StartTime =
                        tc.Attribute("start-time") != null
                            ? tc.Attribute("start-time").Value
                            : "";
                    test.StartTime =
                        String.IsNullOrEmpty(test.StartTime) && (tc.Attribute("time") != null)
                            ? tc.Attribute("time").Value
                            : test.StartTime;
                    test.EndTime =
                        tc.Attribute("end-time") != null
                            ? tc.Attribute("end-time").Value
                            : "";

                    // description
                    var description =
                        tc.Descendants("property")
                        .Where(c => c.Attribute("name").Value.Equals("Description", StringComparison.CurrentCultureIgnoreCase));
                    test.Description =
                        description.Count() > 0
                            ? description.ToArray()[0].Attribute("value").Value
                            : "";

                    // get test case level categories
                    var categories = this.GetCategories(tc, true);

                    // if this is a parameterized test, get the categories from the parent test-suite
                    var parameterizedTestElement = tc
                                                   .Ancestors("test-suite").ToList()
                                                   .Where(x => x.Attribute("type").Value.Equals("ParameterizedTest", StringComparison.CurrentCultureIgnoreCase))
                                                   .FirstOrDefault();

                    if (null != parameterizedTestElement)
                    {
                        var paramCategories = this.GetCategories(parameterizedTestElement, false);
                        categories.UnionWith(paramCategories);
                    }

                    //Merge test level categories with suite level categories and add to test and report
                    categories.UnionWith(suiteCategories);
                    test.CategoryList.AddRange(categories);
                    report.CategoryList.AddRange(categories);


                    // error and other status messages
                    test.StatusMessage =
                        tc.Element("failure") != null
                            ? tc.Element("failure").Element("message").Value.Trim()
                            : "";
                    test.StatusMessage +=
                        tc.Element("failure") != null
                            ? tc.Element("failure").Element("stack-trace") != null
                                ? tc.Element("failure").Element("stack-trace").Value.Trim()
                                : ""
                            : "";

                    test.StatusMessage += tc.Element("reason") != null && tc.Element("reason").Element("message") != null
                        ? tc.Element("reason").Element("message").Value.Trim()
                        : "";

                    // add NUnit console output to the status message
                    test.StatusMessage += tc.Element("output") != null
                     ? tc.Element("output").Value.Trim()
                     : "";

                    testSuite.TestList.Add(test);
                });
                testSuite.TestList = testSuite.TestList.OrderByDescending(l => l.Status).ToList();
                testSuite.Status   = ReportUtil.GetFixtureStatus(testSuite.TestList);

                report.TestSuiteList.Add(testSuite);
                report.TestSuiteList = report.TestSuiteList.OrderByDescending(x => x.Status).ToList();
            });

            //Sort category list so it's in alphabetical order
            report.CategoryList.Sort();

            return(report);
        }
Example #34
0
 public abstract void OnTestSuiteExecutionBegin(TestSuite testSuite, TestSuiteBeginExecutionArgs args);
        public TestReport Run(string specificTestName = null, bool skipLocal = false)
        {
            var testSuiteTypes = GetTestSuiteTypesUsingReflection(skipLocal);

            if (testSuiteTypes == null || testSuiteTypes.Length == 0)
            {
                return(new TestReport()
                {
                    Tests = new List <TestReportItem>()
                });
            }

            var testPackage = new TestPackage("HelthMonitor test package");
            var testSuite   = new TestSuite("HelthMonitor test suite");

            TestExecutionContext.CurrentContext.TestPackage = testPackage;

            if (string.IsNullOrEmpty(specificTestName))
            {
                foreach (var testSuiteType in testSuiteTypes)
                {
                    var test = TestFixtureBuilder.BuildFrom(testSuiteType);
                    testSuite.Tests.Add(test);
                }
            }
            else
            {
                Test   specificTest       = null;
                string specificTestMethod = null;

                if (specificTestName.Contains("#"))
                {
                    var tokens = specificTestName.Split('#');

                    specificTestName   = tokens[0];
                    specificTestMethod = tokens[1];
                }

                var specificTestType = testSuiteTypes.FirstOrDefault(x => x.FullName == specificTestName);
                if (specificTestType != null)
                {
                    specificTest = TestFixtureBuilder.BuildFrom(specificTestType);
                }

                if (specificTest != null && !string.IsNullOrEmpty(specificTestMethod))
                {
                    var testsToRemove = new List <Test>();
                    foreach (Test test in specificTest.Tests)
                    {
                        var testMethod = test as TestMethod;
                        if (testMethod != null)
                        {
                            if (testMethod.Method.Name != specificTestMethod)
                            {
                                testsToRemove.Add(test);
                            }
                        }
                    }

                    foreach (var test in testsToRemove)
                    {
                        specificTest.Tests.Remove(test);
                    }
                }

                if (specificTest != null)
                {
                    testSuite.Tests.Add(specificTest);
                }
            }

            using (var listener = new NUnitTraceListener(_appInsightsInstrumentationKey))
            {
                var testResult = testSuite.Run(listener, new NUnitTestRunnerFilter());

                var testReport = GenerateTestReport(testResult);
                return(testReport);
            }
        }
Example #36
0
 public override void TearDown()
 {
     m_suite = null;
 }
Example #37
0
        public Result Execute(ExternalCommandData revit, ref string message, ElementSet elements)
        {
            AppDomain.CurrentDomain.AssemblyResolve += Dynamo.Utilities.AssemblyHelper.CurrentDomain_AssemblyResolve;

            //Get the data map from the running journal file.
            IDictionary <string, string> dataMap = revit.JournalData;

            try
            {
                RevitData.Application = revit.Application;
                RevitData.Document    = RevitData.Application.ActiveUIDocument;

                bool canReadData = (0 < dataMap.Count);

                if (canReadData)
                {
                    if (dataMap.ContainsKey("testName"))
                    {
                        testName = dataMap["testName"];
                    }
                    if (dataMap.ContainsKey("fixtureName"))
                    {
                        fixtureName = dataMap["fixtureName"];
                    }
                    if (dataMap.ContainsKey("testAssembly"))
                    {
                        testAssembly = dataMap["testAssembly"];
                    }
                    if (dataMap.ContainsKey("resultsPath"))
                    {
                        resultsPath = dataMap["resultsPath"];
                    }
                    if (dataMap.ContainsKey("runDynamo"))
                    {
                        runDynamo = Convert.ToBoolean(dataMap["runDynamo"]);
                    }
                }

                if (string.IsNullOrEmpty(testAssembly))
                {
                    throw new Exception("Test assembly location must be specified in journal.");
                }

                if (string.IsNullOrEmpty(resultsPath))
                {
                    throw new Exception("You must supply a path for the results file.");
                }

                if (runDynamo)
                {
                    StartDynamo();
                }

                //http://stackoverflow.com/questions/2798561/how-to-run-nunit-from-my-code

                //Tests must be executed on the main thread in order to access the Revit API.
                //NUnit's SimpleTestRunner runs the tests on the main thread
                //http://stackoverflow.com/questions/16216011/nunit-c-run-specific-tests-through-coding?rq=1
                CoreExtensions.Host.InitializeService();
                var    runner          = new SimpleTestRunner();
                var    builder         = new TestSuiteBuilder();
                string testAssemblyLoc = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), testAssembly);

                var package = new TestPackage("DynamoTestFramework", new List <string>()
                {
                    testAssemblyLoc
                });
                runner.Load(package);
                TestSuite suite = builder.Build(package);

                TestFixture fixture = null;
                FindFixtureByName(out fixture, suite, fixtureName);
                if (fixture == null)
                {
                    throw new Exception(string.Format("Could not find fixture: {0}", fixtureName));
                }

                InitializeResults();

                if (!canReadData)
                {
                    var currInvalid = Convert.ToInt16(resultsRoot.invalid);
                    resultsRoot.invalid          = currInvalid + 1;
                    resultsRoot.testsuite.result = "Error";

                    throw new Exception("Journal file's data map contains no information about tests.");
                }

                //find or create a fixture
                var fixtureResult = FindOrCreateFixtureResults(dynamoResults, fixtureName);

                //convert the fixture's results array to a list
                var runningResults = fixtureResult.results.Items.ToList();

                //if the test name is not specified
                //run all tests in the fixture
                if (string.IsNullOrEmpty(testName) || testName == "None")
                {
                    var fixtureResults = RunFixture(fixture);
                    runningResults.AddRange(fixtureResults);
                }
                else
                {
                    var t = FindTestByName(fixture, testName);
                    if (t != null)
                    {
                        if (t is ParameterizedMethodSuite)
                        {
                            var paramSuite = t as ParameterizedMethodSuite;
                            foreach (var tInner in paramSuite.Tests)
                            {
                                if (tInner is TestMethod)
                                {
                                    runningResults.Add(RunTest((TestMethod)tInner));
                                }
                            }
                        }
                        else if (t is TestMethod)
                        {
                            runningResults.Add(RunTest((TestMethod)t));
                        }
                    }
                    else
                    {
                        //we have a journal file, but the specified test could not be found
                        var currInvalid = Convert.ToInt16(resultsRoot.invalid);
                        resultsRoot.invalid          = currInvalid + 1;
                        resultsRoot.testsuite.result = "Error";
                    }
                }

                fixtureResult.results.Items = runningResults.ToArray();

                CalculateCaseTotalsOnSuite(fixtureResult);
                CalculateSweetTotalsOnOuterSweet(rootSuite);
                CalculateTotalsOnResultsRoot(resultsRoot);

                SaveResults();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.StackTrace);
                return(Result.Failed);
            }

            return(Result.Succeeded);
        }
Example #38
0
        private List <Question> GenerateQuestionSet(TestSuite testSuite)
        {
            int    optionalQuestions = Convert.ToInt32(testSuite.OptionalQuestion);
            Random random = new Random();
            int    index, requiredMinutes, minutes;
            List <TestSuiteTag> testSuiteTags;
            List <Question>     questions = new List <Question>();

            var questionBank = _context.Query <Question>().Where(q => !q.IsDeleted && q.Status == QuestionStatus.Approved).ToList();

            if (questionBank != null && questionBank.Any())
            {
                GetTestSuiteTags(testSuite, out testSuiteTags);

                foreach (var tag in testSuiteTags)
                {
                    minutes = 0;
                    var questionList = questionBank.Where(x => x.Tags.Split(',').Contains(Convert.ToString(tag.TagId)) && !questions.Any(y => y.Id == x.Id)).ToList();
                    if (questionList.Sum(x => x.Duration) >= tag.Minutes)
                    {
                        //Optional Questions
                        var optionalQuestion = questionList.Where(x => !questions.Any(y => y.Id == x.Id) && x.QuestionType == 1 && x.ProficiencyLevel == tag.Proficiency);
                        requiredMinutes = tag.Minutes * Convert.ToInt32(optionalQuestions) / 100;
                        if (optionalQuestion.Sum(x => x.Duration) >= requiredMinutes)
                        {
                            do
                            {
                                optionalQuestion = questionList.Where(x => !questions.Any(y => y.Id == x.Id) && x.QuestionType == 1 && x.ProficiencyLevel == tag.Proficiency);
                                index            = random.Next(optionalQuestion.Count());
                                Question question = optionalQuestion.ElementAtOrDefault(index);
                                questions.Add(question);
                                minutes += question.Duration;
                            } while (minutes <= requiredMinutes);
                        }

                        //Practical Questions
                        requiredMinutes = tag.Minutes - minutes;
                        minutes         = 0;
                        var practicalQuestion = questionList.Where(x => !questions.Any(y => y.Id == x.Id) && x.QuestionType == 2 && x.ProficiencyLevel == tag.Proficiency);
                        if (practicalQuestion.Sum(x => x.Duration) >= requiredMinutes)
                        {
                            do
                            {
                                practicalQuestion = questionList.Where(x => !questions.Any(y => y.Id == x.Id) && x.QuestionType == 2 && x.ProficiencyLevel == tag.Proficiency);
                                if (practicalQuestion != null && practicalQuestion.Any())
                                {
                                    index = random.Next(practicalQuestion.Count());
                                    Question question = practicalQuestion.ElementAtOrDefault(index);
                                    if (question != null)
                                    {
                                        questions.Add(question);
                                        minutes += question.Duration;
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            } while (minutes <= requiredMinutes);
                        }
                    }
                }
            }
            return(questions);
        }
Example #39
0
 public int Add(TestSuite TestSuite)
 {
     _context.Add(TestSuite);
     return(TestSuite.TestSuiteId);
 }
Example #40
0
 public void CreateFixture()
 {
     fixture = TestBuilder.MakeFixture(typeof(FixtureWithProperties));
 }
Example #41
0
 public void Show(TestSuite suite)
 {
     NavigationController.PushViewController(suites_dvc [suite], true);
 }
Example #42
0
        public void AddSuite(TestSuite suite)
        {
            var xmlelem = WriteSuite(suite);

            this.root.AppendChild(xmlelem);
        }
 public override void OnTestSuiteExecutionBegin(TestSuite testSuite, TestSuiteBeginExecutionArgs args)
 {
     LogEvent.Debug($"{MethodInfo.GetCurrentMethod().Name} {args.VirtualUser}");
 }
Example #44
0
        public static void FrameworkDriver(string currentTC, string strEnvironment = "", Constants.Scrum eScrum = Constants.Scrum.Default)
        {
            try
            {
                Logger.Info(Constants.ENTERINGMETHOD + System.Reflection.MethodBase.GetCurrentMethod().Name);
                //Logger.Info(Constants.ENTERINGMETHOD);
                string testCasesExcelFile = "";
                string FetchPolicynumbers = "";
                //string FindPolicynumbers = "";

                switch (eScrum)
                {
                case Constants.Scrum.CoreADC:
                    testCasesExcelFile = @".\" + Constants.TESTCOREADC_ASEEXCELFILE;
                    break;

                case Constants.Scrum.CoreVM:
                    testCasesExcelFile = @".\" + Constants.TESTCOREVM_ASEEXCELFILE;
                    break;

                case Constants.Scrum.PaymentsADC:
                    testCasesExcelFile = @".\" + Constants.TESTPAYMENTADC_ASEEXCELFILE;
                    break;

                case Constants.Scrum.DisbursementsADC:
                    testCasesExcelFile = @".\" + Constants.TESTDISBURSEMENTADC_ASEEXCELFILE;
                    break;

                case Constants.Scrum.PaymentsVM:
                    testCasesExcelFile = @".\" + Constants.TESTPAYMENTVM_ASEEXCELFILE;
                    break;

                case Constants.Scrum.Smoke:
                    testCasesExcelFile = @".\" + Constants.SMOKETEST_ASEEXCELFILE;
                    break;

                case Constants.Scrum.Default:
                    //testCasesExcelFile = Library.GetSolutionPath() + @"\UIDesign\UIDesign" + Constants.TESTCASEEXCELFILE;
                    testCasesExcelFile = Directory.GetCurrentDirectory() + Constants.TESTCASEEXCELFILE;
                    break;

                default:
                    testCasesExcelFile = @".\" + Constants.TESTCASEEXCELFILE;
                    break;
                }

                //FindPolicynumbers = Library.GetSolutionPath() + @"\UIDesign\UIDesign" + Constants.TESTPolicynumberEXCELFILE;
                //FindPolicynumbers = Directory.GetCurrentDirectory() + Constants.TESTPolicynumberEXCELFILE;

                DataSet All = Library.ReadExcel(testCasesExcelFile);
                //DataSet DBsetPolicies = Library.ReadExcel(FindPolicynumbers);
                DataTable dtTestSuite = All.Tables[Constants.TESTSUITE];
                //DataTable dtPolicies = DBsetPolicies.Tables[Constants.POLICIES];
                TestSuite currentTS         = new TestSuite(dtTestSuite);
                DataTable dtOutputXPath     = All.Tables[Constants.OUTPUTXPATH];
                DataTable dtEnvironments    = All.Tables[Constants.ENVIRONMENT];
                DataTable dtXPathRepository = All.Tables[Constants.XPATHREPOSITORY];
                DataTable dtCustomHeader    = All.Tables[Constants.CUSTOMHEADER];
                //var PolicynumberRow = from myRow in dtPolicies.AsEnumerable()
                //              where myRow.Field<string>("TestcaseId ") == currentTC.ToString()
                //                   select myRow.Field<string>("Policynumbers").ToString();
                //foreach (var row in PolicynumberRow)
                //{
                //    FetchPolicynumbers = row.ToString();
                //}
                Logger.Info(Constants.LOGFILEHEADER);
                Logger.Info(Constants.LOGSTARTTESTCASEHEADER);
                Logger.Info(Constants.LOGFILEHEADER);
                Logger.Info(Constants.TESTCASEID + currentTC);
                XDocument reqXML        = null;
                XDocument resXML        = null;
                string    CurrentXML    = null;
                bool      Success       = false;
                bool      bSkipTestCase = false;
                Library.Keywords.Clear();
                string sLOB             = null;
                string sActualcurrentTC = null;
                System.Threading.Thread.Sleep(5000);

                //sLOB = ConfigurationManager.AppSettings["LOB"].ToString().Trim();
                //sLOB = (sLOB.ToUpper() == "AUTO" ? "" : sLOB);
                //if (sLOB != "")
                //{
                //    DataRow[] ChkFilteredTableForProductSelection = dtTestSuite.DefaultView.ToTable(true, new string[] { "User Story", "Test Case" }).Select("[Test Case] Like '" + currentTC + "%'");

                //    if (ChkFilteredTableForProductSelection.Length > 2)
                //    {
                //        bSkipTestCase = true;
                //        Logger.Info("Duplicate Test Case Identified. Test Case # : " + currentTC);
                //    }
                //    else if (ChkFilteredTableForProductSelection.Length == 2)
                //    {
                //        DataRow[] FilteredTableForProductSelection = dtTestSuite.DefaultView.ToTable(true, new string[] { "User Story", "Test Case" }).Select("[Test Case] = '" + currentTC + "_" + sLOB + "'");
                //        if (FilteredTableForProductSelection.Length == 1)
                //        {
                //            sActualcurrentTC = currentTC;
                //            currentTC = currentTC + "_" + sLOB;
                //        }
                //    }
                //}
                string environment = string.Empty;
                foreach (TestCase currentTCDetails in currentTS.TestCases[currentTC])
                {
                    if ((currentTCDetails.Execute == Constants.Yes) && (bSkipTestCase == false))
                    {
                        currentTCDetails.StartTime = DateTime.Now;
                        Logger.Info(Constants.LOGFILEHEADER);
                        Logger.Info(Constants.LOGSTARTTESTSTEPHEADER);
                        Logger.Info(Constants.LOGFILEHEADER);

                        if ((currentTCDetails.Action != Constants.VALIDATE) && (currentTCDetails.Action != Constants.NOVALIDATE))
                        {
                            string strUriEnv = null;
                            if (strEnvironment == "NA")
                            {
                                strUriEnv = currentTCDetails.URI;
                            }
                            else
                            {
                                strUriEnv = currentTCDetails.URI + (strEnvironment == "" ? currentTCDetails.Environment : strEnvironment);
                            }
                            string strFilter = string.Format("[{0}]='{1}'", Constants.environment, strUriEnv);
                            if ((!currentTCDetails.Action.Equals("~~URI1-Request")) & (!currentTCDetails.Action.Equals("~~URI2-Request")) &
                                (!currentTCDetails.Action.Equals("GET-~~URI1-Negative Request")) & (!currentTCDetails.Action.Equals("GET-~~URI1-Request"))
                                & (!currentTCDetails.Action.Equals("~~URI3-Request")) & (!currentTCDetails.Action.Equals("~~URI4-Request"))
                                & (!currentTCDetails.Action.Equals("~~URI5-Request")) & (!currentTCDetails.Action.Equals("~~URI6-Request"))
                                & (!currentTCDetails.Action.Equals("~~URI7-Request")) & (!currentTCDetails.Action.Equals("~~URI8-Request"))
                                & (!currentTCDetails.Action.Equals("~~URI-Request")))
                            {
                                environment = dtEnvironments.Select(strFilter)[0].ItemArray[1].ToString().Replace("AfterIssuePolicyNumber", FetchPolicynumbers);
                            }
                            ;
                            if (!currentTCDetails.Action.Contains("Request"))
                            {
                                environment = Library.ReplaceURIwithGivenKeyword(currentTCDetails, environment);
                            }
                            if (currentTCDetails.XMLFile.Contains("JSonTemplt"))
                            {
                                string[]  sheetNXmlFile = currentTCDetails.XMLFile.Split('-');
                                DataTable dtInputXPath  = All.Tables[sheetNXmlFile[0].ToString()];
                                currentTCDetails.strRequest = Library.BuildJSonRequestFromExcel(dtInputXPath, currentTC);
                            }
                            else if (currentTCDetails.XMLFile.Contains("Tmplt"))
                            {
                                DataTable dtInputXPath = All.Tables[currentTCDetails.XMLFile];
                                //string XMLFilePath = Library.GetSolutionPath() + @"\UIDesign\UIDesign" + Constants.XMLTEMPLATEPATH + currentTCDetails.XMLFile;
                                string XMLFilePath = Directory.GetCurrentDirectory() + Constants.XMLTEMPLATEPATH + currentTCDetails.XMLFile;


                                Logger.Info("Tmplt XML File Path # : " + XMLFilePath);
                                currentTCDetails.RequestXML = Library.BuildXMLFromXPath(XMLFilePath, currentTC, currentTCDetails.XMLFile, dtInputXPath, dtXPathRepository, FetchPolicynumbers);
                            }
                            else if (currentTCDetails.Action.Contains("Request") && !currentTCDetails.XMLFile.Contains("NA"))
                            {
                                string[]  sheetNXmlFile = currentTCDetails.XMLFile.Split('-');
                                DataTable dtInputXPath  = All.Tables[sheetNXmlFile[0].ToString()];

                                if (sActualcurrentTC == null)
                                {
                                    sActualcurrentTC = currentTC;
                                }

                                DirectoryInfo          dirTestCases = new System.IO.DirectoryInfo(@".\" + Constants.TESTDATAXMLS + (sActualcurrentTC != currentTC ? sActualcurrentTC : currentTCDetails.TCNbr));
                                IEnumerable <FileInfo> xmlFileList  = dirTestCases.GetFiles("*.xml", System.IO.SearchOption.AllDirectories);
                                foreach (FileInfo xmlFile in xmlFileList)
                                {
                                    string xmlFileName = xmlFile.Name.Replace(".Rq.xml", "");
                                    if (xmlFileName == sheetNXmlFile[1].ToString())
                                    {
                                        Logger.Info("Request XML File Path # : " + xmlFile.FullName);
                                        currentTCDetails.RequestXML = Library.BuildXMLFromXPath(xmlFile.FullName, currentTC, (sActualcurrentTC != currentTC ? sActualcurrentTC : currentTCDetails.TCNbr), dtInputXPath, dtXPathRepository);
                                    }
                                }
                            }
                            if (currentTCDetails.Action.Contains("Request"))
                            {
                                //WebService objWebService = new WebService();
                                WebService objWebService = new WebService(dtEnvironments, strFilter);
                                string     strResponse   = "";
                                if (currentTCDetails.Action.Contains("POST JSON"))
                                {
                                    strResponse = objWebService.MakeServiceCall(HttpMethod.Post, environment, (currentTCDetails.strRequest == null ? "" : currentTCDetails.strRequest), dtCustomHeader, currentTC, out Success, ((currentTCDetails.RequestHeader.Trim() == "" || currentTCDetails.RequestHeader.Trim().ToLower().Contains("optional")) ? Constants.sDefaultContentType : currentTCDetails.RequestHeader));
                                }
                                else if (currentTCDetails.Action.Contains("GET"))
                                {
                                    strResponse = objWebService.MakeServiceCall(HttpMethod.Get, environment, (currentTCDetails.RequestXML == null ? "" : currentTCDetails.RequestXML.ToString()), dtCustomHeader, currentTC, out Success, ((currentTCDetails.RequestHeader.Trim() == "" || currentTCDetails.RequestHeader.Trim().ToLower().Contains("optional")) ? Constants.sDefaultContentType : currentTCDetails.RequestHeader));
                                }
                                else
                                {
                                    System.Net.ServicePointManager.Expect100Continue = false;
                                    strResponse = objWebService.MakeServiceCall(HttpMethod.Post, environment, (currentTCDetails.RequestXML == null ? "" : currentTCDetails.RequestXML.ToString()), dtCustomHeader, currentTC, out Success, ((currentTCDetails.RequestHeader.Trim() == "" || currentTCDetails.RequestHeader.Trim().ToLower().Contains("optional")) ? Constants.sDefaultContentType : currentTCDetails.RequestHeader));
                                }

                                if (((Success) && currentTCDetails.Action.Contains("-Action Request") != true) || (currentTCDetails.Action.Contains("-Negative Request") && (Success == false)))
                                {
                                    //if (!strResponse.ToLower().StartsWith("{"))
                                    //{ currentTCDetails.ResponseXML = XDocument.Parse(strResponse); }
                                    //else
                                    { //currentTCDetails.ResponseXML = JsonConvert.DeserializeXmlNode(strResponse.ToString(), "root");
                                        //currentTCDetails.ResponseXML = JsonConvert.DeserializeXmlNode("{\"Row\":" + strResponse + "}", "root");
                                        currentTCDetails.ResponseXML = JsonConvert.DeserializeXNode("{\"Row\":" + strResponse + "}", "root");
                                    }

                                    Library.ReplaceXMLFromXPath(currentTCDetails, currentTC, dtOutputXPath, dtXPathRepository);
                                    reqXML = currentTCDetails.RequestXML;
                                    resXML = currentTCDetails.ResponseXML;
                                }
                                else if ((Success) && currentTCDetails.Action.Contains("-Action Request"))
                                {
                                }
                                else
                                {
                                    currentTCDetails.Result = Constants.FAIL;
                                    bSkipTestCase           = true;
                                    Logger.Info("Service is not responded properly" + "Request : " + (currentTCDetails.RequestXML == null ? "" : currentTCDetails.RequestXML.ToString()) + "\n" + " Response : " + strResponse);
                                    throw new AssertFailedException("Service is not responded properly" + "Request : " + (currentTCDetails.RequestXML == null ? "" : currentTCDetails.RequestXML.ToString()) + "\n" + " Response : " + strResponse);
                                }
                            }

                            if ((Success) || (currentTCDetails.Action.Contains("-Negative Request") && (Success == false)))
                            {
                                currentTCDetails.Result = Constants.PASS;

                                switch (currentTCDetails.XMLFile.ToLower())
                                {
                                case "policy.tmplt.rq.xml":
                                case "policy.cycle.tmplt.rq.xml":
                                case "policy-rpm.tmplt.rq.xml":
                                case "cycle-rpm.tmplt.rq.xml":
                                case "cycle.tmplt.rq.xml":
                                case "umbrella.tmplt.rq.xml":
                                    Library.ValidatePolicyXMLFromXPath(currentTCDetails, "000000", dtOutputXPath, dtXPathRepository);

                                    if (currentTCDetails.Results.Count > 0)
                                    {
                                        var Fail = currentTCDetails.Results.FindAll(v => v.Result == Constants.FAIL);
                                        var Pass = currentTCDetails.Results.FindAll(v => v.Result == Constants.PASS);
                                        if (Pass.Count > 0)
                                        {
                                            currentTCDetails.Result = Constants.PASS;
                                            Library.BuildDictonaryObjectFromXML(currentTCDetails, "000000", dtOutputXPath, dtXPathRepository);
                                        }
                                        if (Fail.Count > 0)
                                        {
                                            currentTCDetails.Result = Constants.FAIL;
                                            bSkipTestCase           = true;
                                            Logger.Info("Policy is not Issued Properly");
                                            throw new AssertFailedException("Policy is not Issued Properly");
                                        }
                                    }
                                    break;

                                default:
                                    break;
                                }
                            }
                            else if (currentTCDetails.Action.Contains("~ISSUEDPOLICYNUMBER"))
                            {
                            }
                            else
                            {
                                currentTCDetails.Result = Constants.FAIL;
                                bSkipTestCase           = true;
                                Logger.Info("Service is not responded properly");
                                throw new AssertFailedException("Service is not responded properly");
                            }

                            CurrentXML = currentTCDetails.XMLFile;
                        }
                        else if (currentTCDetails.Action == Constants.NOVALIDATE)
                        {
                            currentTCDetails.Result = Constants.PASS;
                        }
                        else
                        {
                            currentTCDetails.RequestXML  = reqXML;
                            currentTCDetails.ResponseXML = resXML;
                            currentTCDetails.XMLFile     = CurrentXML;
                            Library.ValidateXMLFromXPath(currentTCDetails, currentTC, dtOutputXPath, dtXPathRepository);
                            if (currentTCDetails.Results.Count > 0)
                            {
                                var Fail = currentTCDetails.Results.FindAll(v => v.Result == Constants.FAIL);
                                var Pass = currentTCDetails.Results.FindAll(v => v.Result == Constants.PASS);
                                if (Pass.Count > 0)
                                {
                                    currentTCDetails.Result = Constants.PASS;
                                }
                                if (Fail.Count > 0)
                                {
                                    currentTCDetails.Result = Constants.FAIL;
                                    //throw new AssertFailedException("Test Validation Failed");
                                }
                            }
                        }
                        currentTCDetails.EndTime = DateTime.Now;
                        Logger.Info(Constants.cStep + currentTCDetails.Steps);
                        Logger.Info(Constants.cURI + currentTCDetails.URI);
                        Logger.Info(Constants.cAction + currentTCDetails.Action);
                        Logger.Info(Constants.cEnv + (strEnvironment == "" ? currentTCDetails.Environment : strEnvironment));
                        Logger.Info(Constants.cUserStory + currentTCDetails.UserStory);
                        Logger.Info(Constants.LOGFILEHEADER);
                        Logger.Info(Constants.LOGENDTESTSTEPHEADER);
                        Logger.Info(Constants.LOGFILEHEADER);
                    }
                }
                Logger.Info(Constants.LOGFILEHEADER);
                Logger.Info(Constants.LOGENDTESTCASEHEADER);
                Logger.Info(Constants.LOGFILEHEADER);
                Library.GenerateHTMLReport(currentTS, currentTC);
                Logger.Info(Constants.EXITINGMETHOD + System.Reflection.MethodBase.GetCurrentMethod().Name);
                //Logger.Info(Constants.EXITINGMETHOD);
            }
            catch (Exception ex)
            {
                Logger.Info("webserviceframworkdriver : " + (ex.InnerException == null ? ex.StackTrace.ToString() : ex.InnerException.ToString()));
                throw new AssertFailedException(ex.Message);
            }
        }
 public override void OnTestPreprocessorBegin(TestSuite testSuite, TestProcessorBeginExecutionArgs args)
 {
 }
Example #46
0
        private TestSuite m_suite = null;   // TestSuite instance for testing

        public override void SetUp()
        {
            m_suite = new TestSuite();
        }
 public void SetUp()
 {
     testSuite = new TestSuite("Mock Test Suite");
     testSuite.Add(TestBuilder.MakeFixture(typeof(MockTestFixture)));
     mock3 = (NUnit.Core.TestCase)TestFinder.Find("MockTest3", testSuite);
 }
Example #48
0
 /// <summary>
 /// Construct a CompositeWorkItem for executing a test suite
 /// using a filter to select child tests.
 /// </summary>
 /// <param name="suite">The TestSuite to be executed</param>
 /// <param name="childFilter">A filter used to select child tests</param>
 public CompositeWorkItem(TestSuite suite, ITestFilter childFilter) : base(suite)
 {
     _suite       = suite;
     _childFilter = childFilter;
 }
 public override void OnTestPostprocessorComplete(TestSuite testSuite, TestProcessorResult testProcessorResult)
 {
 }
    public void saveValues()
    {
        string alertmessage  = "";
        string value1        = "";
        string value         = "";
        double thresholdval  = 2.0F;
        int    experimentVal = 0;

        InputAlgorithm = GameObject.Find("Algorithm").GetComponent <Dropdown>();
        string InputAlgorithmValue = InputAlgorithm.captionText.text;

        MazeSize = GameObject.Find("MazeSize").GetComponent <Dropdown>();
        string    MazeSizeValue   = MazeSize.captionText.text;
        TestSuite ts              = new TestSuite();
        int       mazecoverageval = Convert.ToInt32(MazeCoverage.value);

        try
        {
            value1        = (NumberOfExperiments.value).ToString();
            experimentVal = int.Parse(value1);
        }
        catch (FormatException fe)
        {
            alertmessage += "Kindly enter the value of Number of Experiments or Enter values in range 1 to 100";
            Result.text   = alertmessage;
        }

        try
        {
            value        = (Thresholdvalue.value).ToString();
            thresholdval = float.Parse(value);
        }
        catch (FormatException fe)
        {
            alertmessage += "Kindly enter the value of Placement Threshold or Enter values in range 0 to 1";
            Result.text   = alertmessage;
        }
        SensorType = GameObject.Find("SensorType").GetComponent <Dropdown>();
        string SensorTypeValue = SensorType.captionText.text;

        print(thresholdval);
        if ((!string.IsNullOrEmpty(value) && (thresholdval > 0 && thresholdval < 1)) && !string.IsNullOrEmpty(value1) && (experimentVal >= 1 && experimentVal <= 100))
        {
            database db = new database();
            thresholdval = Math.Round(thresholdval, 2);
            //inputs = new string[] { InputAlgorithmValue, MazeSizeValue, SensorTypeValue, ExperimentType.captionText.text };
            //ts.testUpdateText(inputs);
            Result.text = "All Values are valid. Please click Create Maze";
        }
        else
        {
            alertmessage = "Kindly enter the valid Values";
            Result.text  = alertmessage;
        }

        PlayerPrefs.SetInt("MazeCoverage", mazecoverageval);
        PlayerPrefs.SetString("Algo", InputAlgorithmValue);
        PlayerPrefs.SetString("Maze", thresholdval.ToString());
        PlayerPrefs.SetString("Size", MazeSizeValue);
        PlayerPrefs.SetString("Sensor", SensorTypeValue);
        PlayerPrefs.SetInt("Iteration", experimentVal);
        PlayerPrefs.SetString("Experiment", ExperimentType.captionText.text);
        PlayerPrefs.Save();
    }
 public override TestConfiguration Resolve()
 {
     return(TestSuite.GetConfiguration <WebDavConfiguration> ());
 }
Example #52
0
 public ParallelExecutionTests(TestSuite testSuite)
 {
     _testSuite = testSuite;
 }
Example #53
0
        public Result Execute(ExternalCommandData revit, ref string message, ElementSet elements)
        {
            DynamoLogger.Instance.StartLogging();

            // Get the StringStringMap class which can write support into.
            IDictionary <string, string> dataMap = revit.JournalData;

            try
            {
                m_revit = revit.Application;
                m_doc   = m_revit.ActiveUIDocument;

                #region default level

                Level defaultLevel = null;
                var   fecLevel     = new FilteredElementCollector(m_doc.Document);
                fecLevel.OfClass(typeof(Level));
                defaultLevel = fecLevel.ToElements()[0] as Level;

                #endregion

                dynRevitSettings.Revit        = m_revit;
                dynRevitSettings.Doc          = m_doc;
                dynRevitSettings.DefaultLevel = defaultLevel;

                //create dynamo
                Regex  r       = new Regex(@"\b(Autodesk |Structure |MEP |Architecture )\b");
                string context = r.Replace(m_revit.Application.VersionName, "");

                var dynamoController = new DynamoController_Revit(DynamoRevitApp.env, DynamoRevitApp.updater, typeof(DynamoRevitViewModel), context);

                //flag to run evalauation synchronously, helps to
                //avoid threading issues when testing.
                dynamoController.Testing = true;

                //execute the tests
                Results = new DynamoRevitTestRunner();
                //var resultsView = new DynamoRevitTestResultsView();
                //resultsView.DataContext = Results;

                //http://stackoverflow.com/questions/2798561/how-to-run-nunit-from-my-code
                string assLocation = Assembly.GetExecutingAssembly().Location;
                var    fi          = new FileInfo(assLocation);
                string testLoc     = Path.Combine(fi.DirectoryName, @"DynamoRevitTester.dll");

                //Tests must be executed on the main thread in order to access the Revit API.
                //NUnit's SimpleTestRunner runs the tests on the main thread
                //http://stackoverflow.com/questions/16216011/nunit-c-run-specific-tests-through-coding?rq=1
                CoreExtensions.Host.InitializeService();
                var runner  = new SimpleTestRunner();
                var builder = new TestSuiteBuilder();
                var package = new TestPackage("DynamoRevitTests", new List <string>()
                {
                    testLoc
                });
                runner.Load(package);
                TestSuite   suite   = builder.Build(package);
                TestFixture fixture = null;
                FindFixtureByName(out fixture, suite, "DynamoRevitTests");
                if (fixture == null)
                {
                    throw new Exception("Could not find DynamoRevitTests fixture.");
                }

                //foreach (var t in fixture.Tests)
                //{
                //    if (t is ParameterizedMethodSuite)
                //    {
                //        var paramSuite = t as ParameterizedMethodSuite;
                //        foreach (var tInner in paramSuite.Tests)
                //        {
                //            if (tInner is TestMethod)
                //                Results.Results.Add(new DynamoRevitTest(tInner as TestMethod));
                //        }
                //    }
                //    else if (t is TestMethod)
                //        Results.Results.Add(new DynamoRevitTest(t as TestMethod));
                //}

                //resultsView.ShowDialog();

                //for testing
                //if the journal file contains data
                bool canReadData = (0 < dataMap.Count) ? true : false;
                if (canReadData)
                {
                    //revit.Application.OpenAndActivateDocument(dataMap["dynamoModel"]);
                    //dynamoController.DynamoViewModel.OpenCommand.Execute(dataMap["dynamoGraph"]);
                    //dynamoController.DynamoViewModel.RunExpressionCommand.Execute(null);

                    TestMethod t = FindTestByName(fixture, dataMap["dynamoTestName"]);
                    if (t != null)
                    {
                        //Results.Results.Add(new DynamoRevitTest(t as TestMethod));
                        //Results.RunAllTests(null);
                        var dynTest = new DynamoRevitTest(t as TestMethod);
                        dynTest.Run(null);
                        dynTest.Save();
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
                return(Result.Failed);
            }

            return(Result.Succeeded);
        }
Example #54
0
        static void Main(String[] args)
        {
            var websites = new UrlTests(
                extension: ".html",
                withBuffer: true);

            websites.Include(
                "http://www.amazon.com",
                "http://www.blogspot.com",
                "http://www.smashing.com",
                "http://www.youtube.com",
                "http://www.weibo.com",
                "http://www.yahoo.com",
                "http://www.google.com",
                "http://www.linkedin.com",
                "http://www.pinterest.com",
                "http://news.google.com",
                "http://www.baidu.com",
                "http://www.codeproject.com",
                "http://www.ebay.com",
                "http://www.msn.com",
                "http://www.nbc.com",
                "http://www.qq.com",
                "http://www.florian-rappl.de",
                "http://www.stackoverflow.com",
                "http://www.html5rocks.com/en",
                "http://www.live.com",
                "http://www.taobao.com",
                "http://www.huffingtonpost.com",
                "http://www.wordpress.org",
                "http://www.myspace.com",
                "http://www.flickr.com",
                "http://www.godaddy.com",
                "http://www.reddit.com",
                "http://www.nytimes.com",
                "http://peacekeeper.futuremark.com",
                "http://www.pcmag.com",
                "http://www.sitepoint.com",
                "http://html5test.com",
                "http://www.spiegel.de",
                "http://www.tmall.com",
                "http://www.sohu.com",
                "http://www.vk.com",
                "http://www.wordpress.com",
                "http://www.bing.com",
                "http://www.tumblr.com",
                "http://www.ask.com",
                "http://www.mail.ru",
                "http://www.imdb.com",
                "http://www.kickass.to",
                "http://www.360.cn",
                "http://www.163.com",
                "http://www.neobux.com",
                "http://www.aliexpress.com",
                "http://www.netflix.com",
                "http://www.w3.org/TR/html5/single-page.html",
                "http://en.wikipedia.org/wiki/South_African_labour_law").Wait();

            var parsers = new List <ITestee>
            {
                new AngleSharpParser(),
                new CsQueryParser(),
                new AgilityPackParser()
            };

            var testsuite = new TestSuite(parsers, websites.Tests, new Output(), new Warmup())
            {
                NumberOfRepeats = 5,
                NumberOfReRuns  = 1
            };

            testsuite.Run();
        }
Example #55
0
 public ParallelExecutionTests(TestSuite testSuite, Expectations expectations)
 {
     _testSuite    = testSuite;
     _expectations = expectations;
 }