Ejemplo n.º 1
0
 public void AddTest(Test test)
 {
     lock (_synclock)
     {
         UpdateTestStatusCounts(test);
         TestCollection.Add(test);
     }
 }
Ejemplo n.º 2
0
        public void ToList_TouchCountWithICollection()
        {
            TestCollection <int> source = new TestCollection <int>(new int[] { 1, 2, 3, 4 });
            var resultList = source.ToListUsePool();

            Assert.Equal(source, resultList);
            Assert.Equal(1, source.CountTouched);
        }
Ejemplo n.º 3
0
 public void Dispose()
 {
     if (_testCollection != null)
     {
         _testCollection.Dispose();
         _testCollection = null;
     }
 }
Ejemplo n.º 4
0
 internal object TestMethod(TestCollection t)
 {
     foreach (object x in t)
     {
         return(x);
     }
     return(null);
 }
Ejemplo n.º 5
0
        private static TestCollection GetTestCollection(Type testClass, Type collectionType)
        {
            var reflectionTypeInfo = GetCollectionTypeInfo(collectionType);
            var testAssembly       = GetTestAssembly(testClass);
            var retval             = new TestCollection(testAssembly, reflectionTypeInfo, "test collection displayName");

            return(retval);
        }
Ejemplo n.º 6
0
	internal object TestMethod (TestCollection t)
	{
		foreach (object x in t)
		{
			return x;
		}
		return null;
	}
Ejemplo n.º 7
0
        public void ToList_UseCopyToWithICollection()
        {
            TestCollection <int> source = new TestCollection <int>(new int[] { 1, 2, 3, 4 });
            var resultList = source.ToList();

            Assert.Equal(source, resultList);
            Assert.Equal(1, source.CopyToTouched);
        }
Ejemplo n.º 8
0
 public void RefreshTestStatusCounts()
 {
     lock (_synclock)
     {
         Passed = Failed = Skipped = Others = 0;
     }
     TestCollection.ForEach(x => UpdateTestStatusCounts(x));
 }
Ejemplo n.º 9
0
 public TestFailed(Exception ex)
 {
     TestCase = new TestCase();
     TestCollection = new TestCollection();
     ExceptionType = ex.GetType().FullName;
     Message = ExceptionUtility.GetMessage(ex);
     StackTrace = ExceptionUtility.GetStackTrace(ex);
 }
Ejemplo n.º 10
0
        public void ToArray_TouchCountWithICollection()
        {
            TestCollection <int> source = new TestCollection <int>(new int[] { 1, 2, 3, 4 });
            var resultArray             = source.ToArray();

            Assert.Equal(source, resultArray);
            Assert.Equal(1, source.CountTouched);
        }
Ejemplo n.º 11
0
 private void AlterModel(ObservableCollection <ListObjectModel> obj)
 {
     TestCollection.Clear();
     foreach (var a in obj)
     {
         TestCollection.Add(a.Clone() as ListObjectModel);
     }
 }
        public void CannotAppendToBuilderOnceCollectionIsCreated()
        {
            TestCollectionBuilder builder = _composition.WithCollectionBuilder <TestCollectionBuilder>();

            IServiceProvider factory = _composition.CreateServiceProvider();
            TestCollection   col     = builder.CreateCollection(factory);

            Assert.Throws <InvalidOperationException>(() => builder.Append <Resolved1>());
        }
        private void LoadManifest(ManifestViewModel manifestViewModel)
        {
            if (manifestViewModel == null)
            {
                return;
            }

            Manifest manifest = null;

            try
            {
                manifest = _manifestService.GetManifest(SelectedManifest.Name);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error Loading Manifest", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            if (manifest == null)
            {
                return;
            }

            manifestViewModel.TestCollections.Clear();
            SelectedManifest.DomainOverride = manifest.OverrideDomain;

            foreach (var testCollectionFile in manifest.Files)
            {
                TestCollection testCollection = null;

                try
                {
                    testCollection = _testCollectionService.GetTestCollection(testCollectionFile);
                }
                catch (Exception e)
                {
                    MessageBox.Show("TestCollection: " + testCollectionFile + Environment.NewLine + e.Message,
                                    "Error Loading TestCollection", MessageBoxButton.OK, MessageBoxImage.Error);
                }

                if (testCollection == null)
                {
                    continue;
                }

                manifestViewModel.TestCollections.Add(new TestCollectionSummaryViewModel
                {
                    IsEnabled = testCollection.Enabled,
                    Name      = testCollection.File,
                    IsEnabledChangedCommand = new RelayCommand(enabled =>
                    {
                        testCollection.Enabled = (bool)enabled;
                        _testCollectionService.SaveTestCollection(testCollection);
                    })
                });
            }
        }
Ejemplo n.º 14
0
        public void ToDictionary_KeyValueSelectorsWork()
        {
            TestCollection <int> collection = new TestCollection <int>(new int[] { 1, 2, 3, 4, 5, 6 });

            Dictionary <int, int> result = collection.ToDictionary(key => key + 10, val => val + 100);

            Assert.Equal(collection.Items.Select(o => o + 10), result.Keys);
            Assert.Equal(collection.Items.Select(o => o + 100), result.Values);
        }
Ejemplo n.º 15
0
        public void Run_PassingTests_ShouldNotThrow()
        {
            var tests = new TestCollection();

            tests.AddTest("Test1", () => { });
            tests.AddTest("Test2", () => { });

            tests.RunTests("MyTests");
        }
Ejemplo n.º 16
0
        public void Run_PassingAsyncTests_ShouldNotThrow()
        {
            var tests = new TestCollection();

            tests.AddTest("Test1", async() => await Task.Delay(1).ConfigureAwait(false));
            tests.AddTest("Test2", async() => await Task.Delay(1).ConfigureAwait(false));

            tests.RunTests("MyTests");
        }
Ejemplo n.º 17
0
        public void InstantiatedCollection_LoadingFromJson_ShouldReturnMatchingDocument()
        {
            var collection = new TestCollection(_documentsStore);
            var document   = collection.TrackDocumentFromJsonContent("{ \"Id\":\"id\", \"AnyNumber\":5 }");

            Assert.Equal("id", document.Content.Id);
            Assert.Equal(5, document.Content.AnyNumber);
            Assert.Equal(document.Id, document.Content.Id);
        }
Ejemplo n.º 18
0
 public TestFailed(Exception ex)
 {
     TestCase       = new TestCase();
     TestCollection = new TestCollection();
     ExceptionType  = ex.GetType().FullName;
     Output         = String.Empty;
     Message        = ExceptionUtility.GetMessage(ex);
     StackTrace     = ExceptionUtility.GetStackTrace(ex);
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += this.OnSuspending;

            TestCollection.AddTests(typeof(App).GetType().GetTypeInfo().Assembly);

            Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
        }
        private void GetImageTests(TestCollection Tests)
        {
            var ImgTests = from test in Tests where test.TestType.ResultType == "image" select test;

            this.imageTests = new TestResultViewModelCollection();
            foreach (Test test in ImgTests)
            {
                this.imageTests.Add(new TestResultViewModel(this.Admittance, test));
            }
        }
        public void AddTest(Test test)
        {
            if (TestCollection == null)
            {
                TestCollection = new List <Test>();
            }

            updateTestStatusCounts(test);
            TestCollection.Add(test);
        }
Ejemplo n.º 22
0
        static void Main(string[] _)
        {
            var info = AssemblyDefinition.ReadAssembly(Assembly.GetExecutingAssembly().Location).MainModule.GetType("JazSharp.ManualTest.Program").Methods;

            using (var testCollection = TestCollection.FromSources(new[] { @"C:\Users\seamillo\source\repos\JazSharp\JazSharp.Tests\bin\Debug\netcoreapp2.2\JazSharp.Tests.dll" }))
                using (var testRun = testCollection.CreateTestRun())
                {
                    var result = testRun.ExecuteAsync().Result;
                }
        }
Ejemplo n.º 23
0
        public void AddTest(Test test)
        {
            // prevent adding duplicate tests
            if (TestCollection.Where(x => x.TestId == test.TestId).Count() > 0)
            {
                return;
            }

            TestCollection.Add(test);
        }
Ejemplo n.º 24
0
        public static async void UsesCustomTestOrderer()
        {
            var collection = new TestCollection(Mocks.TestAssembly(), Reflector.Wrap(typeof(CollectionUnderTest)), null);
            var testCase   = Mocks.XunitTestCase <XunitTestCollectionRunnerTests>("DisposesFixtures", collection);
            var runner     = TestableXunitTestCollectionRunner.Create(testCase);

            await runner.RunAsync();

            Assert.IsType <CustomTestCaseOrderer>(runner.TestCaseOrderer);
        }
Ejemplo n.º 25
0
        static void Main(string[] _)
        {
            var info = AssemblyDefinition.ReadAssembly(Assembly.GetExecutingAssembly().Location).MainModule.GetType("JazSharp.ManualTest.Program").Methods;

            using (var testCollection = TestCollection.FromSources(new[] { typeof(Program).Assembly.Location.Replace("ManualTest", "Tests") }))
                using (var testRun = testCollection.CreateTestRun())
                {
                    var result = testRun.ExecuteAsync().Result;
                }
        }
Ejemplo n.º 26
0
        public void InstantiatedCollection_AddDocument_ShouldSucceed()
        {
            var collection = new TestCollection(_documentsStore);

            var doc = new Document <TestContent>(new TestContent("id", 5));

            collection.Add(doc);

            Assert.Throws <InvalidOperationException>(() => collection.Add(doc));
        }
Ejemplo n.º 27
0
        public void TestPrintSingleColumnCsv()
        {
            var test = new TestCollection <int>();

            for (int i = 0; i < 9; ++i)
            {
                test.Add(i);
            }
            TestPrintAndReload(test);
        }
Ejemplo n.º 28
0
 public void TestPreValidateACollection() {
     const string resource = @"<cfg>
         <things>
             <add name='one' value='something' />
             <add name='two' value='Another' />
         </things>
     </cfg>";
     var actual = new TestCollection(resource, new TraceLogger());
     Assert.AreEqual(1, actual.Errors().Length);
     Assert.AreEqual(3, actual.Things.Count);
 }
        public void CanInsertIntoEmptyBuilder()
        {
            TestCollectionBuilder builder = _composition.WithCollectionBuilder <TestCollectionBuilder>();

            builder.Insert <Resolved2>();

            IServiceProvider factory = _composition.CreateServiceProvider();
            TestCollection   col     = builder.CreateCollection(factory);

            AssertCollection(col, typeof(Resolved2));
        }
        public void WeightedBuilderCreatesWeightedCollection()
        {
            TestCollectionBuilderWeighted builder = _composition.WithCollectionBuilder <TestCollectionBuilderWeighted>()
                                                    .Add <Resolved1>()
                                                    .Add <Resolved2>();

            IServiceProvider factory = _composition.CreateServiceProvider();
            TestCollection   col     = builder.CreateCollection(factory);

            AssertCollection(col, typeof(Resolved2), typeof(Resolved1));
        }
Ejemplo n.º 31
0
        public void SaveTestCollection(TestCollection testCollection)
        {
            var pathRoot = Path.GetFullPath(_configurationService.TestScriptsPath);
            var path     = Path.Combine(pathRoot, testCollection.File);

            var testCollectionJson = JsonConvert.SerializeObject(testCollection, Formatting.Indented, new JsonSerializerSettings {
                DefaultValueHandling = DefaultValueHandling.Ignore
            });

            _fileService.WriteAllText(path, testCollectionJson);
        }
Ejemplo n.º 32
0
    public TestFailed(Exception ex)
    {
        TestCase = new TestCase();
        TestCollection = new TestCollection();
        Output = String.Empty;

        var failureInfo = ExceptionUtility.ConvertExceptionToFailureInformation(ex);
        ExceptionParentIndices = failureInfo.ExceptionParentIndices;
        ExceptionTypes = failureInfo.ExceptionTypes;
        Messages = failureInfo.Messages;
        StackTraces = failureInfo.StackTraces;
    }
Ejemplo n.º 33
0
    public static async void DisposesFixtures()
    {
        var collection = new TestCollection(Mocks.TestAssembly(), Reflector.Wrap(typeof(CollectionUnderTest)), null);
        var testCase   = Mocks.XunitTestCase <XunitTestCollectionRunnerTests>("DisposesFixtures", collection);
        var runner     = TestableXunitTestCollectionRunner.Create(testCase);

        await runner.RunAsync();

        var fixtureUnderTest = runner.CollectionFixtureMappings.Values.OfType <FixtureUnderTest>().Single();

        Assert.True(fixtureUnderTest.Disposed);
    }
        /// <summary>
        /// The load control document.
        /// </summary>
        /// <param name="rootFolder">
        ///     The root folder.
        /// </param>
        /// <param name="controlDocPath">
        ///     The control doc path.
        /// </param>
        /// <param name="testLibraryPath">
        ///     The test library path.
        /// </param>
        /// <param name="deviceFunctions"></param>
        public void LoadTestConfiguration(TestCollection rootFolder, string controlDocPath, string testLibraryPath, List <DeviceFunction> deviceFunctions)
        {
            Log.Enter(this, MethodBase.GetCurrentMethod().Name);

            this.ControlDocumentPath = controlDocPath;
            this.assemblyManager     = new AssemblyManager();

            this.assemblyManager.AddPredefinedTestSuitesFromAssembly(rootFolder, testLibraryPath, deviceFunctions);
            this.assemblyManager.LoadControlDocument(rootFolder, controlDocPath);

            this.ScriptConfigurator.LoadTestScriptSelectionTreeControl(this.AssemblyManager.TestConfiguration);
        }
Ejemplo n.º 35
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            window = new UIWindow (UIScreen.MainScreen.Bounds);

            viewController = new TestTouchViewController ();
            window.RootViewController = viewController;
            window.MakeKeyAndVisible ();

            var test = new TestCollection<string> ();
            test.Add ("Hello World!");

            test.ErrorsChanged += (s,e) => {
                Console.WriteLine ("ERRORS CHANGED!");
            };

            return true;
        }
Ejemplo n.º 36
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button> (Resource.Id.myButton);

            collection = new TestCollection<string> ();

            button.Click += delegate {
                collection.Add (string.Format ("{0} clicks!", collection.Count));
                button.Text = string.Format ("Test Collection: {0}", collection.Count);
            };
        }
        /// <summary>
        /// Create test-process by a jsonConfiguration
        /// </summary>
        /// <param name="jsonConfiguration">Configuration of the current adaptive test.</param>
        /// <param name="listener">Error-Listener</param>
        /// <param name="autoPlugInDetection">If set to true, the system will look for plugins in the current AppDomain</param>
        public TestProcess(string jsonConfiguration, IListener listener, bool autoPlugInDetection = true)
        {
            this.listener = listener;
            plugInManager = new PlugIns.PlugInManager(listener);

            // Load module definitions if autoPlugInDetection is enabled
            if (autoPlugInDetection)
            {
                plugInManager.LoadPlugIns();
            }

            configuration = JsonConvert.DeserializeObject<TestConfiguration>(jsonConfiguration);
                        
            // Validate configuration
            errorsOccured = !Validate(configuration);

            testCollection = new TestCollection();
            testReport = new TestReport(this, configuration.Settings.Output);
        }
Ejemplo n.º 38
0
		public void Init()
		{
			testClassesResultChanged = false;
			testCollection = new TestCollection();
			
			// TestClass1.
			testClass1 = new FakeTest();
			testCollection.Add(testClass1);
			
			// TestClass2.
			testClass2 = new FakeTest();
			testCollection.Add(testClass2);
			
			// TestClass3.
			testClass3 = new FakeTest();
			testCollection.Add(testClass3);
			
			testCollection.PropertyChanged += testCollection_PropertyChanged;
		}
        private void UnitTestManagerForm_Load(object sender, System.EventArgs e)
        {
            if ( this.CurrentUnitTestSession.UnitTestForms.Count > 0 )
            {
                if ( this.CurrentUnitTestSession.UnitTestForms.ContainsKey("uti_" + this.CurrentForm.Name) )
                {
                    // load tests
                    TestCollection tests = this.CurrentUnitTestSession.UnitTestForms["uti_" + this.CurrentForm.Name].Tests;
                    this.FormTests = tests;

                    for (int i=0;i<this.FormTests.Count;i++)
                    {
                        Test t = FormTests.GetByIndex(i);
                        ListViewItem lv = new ListViewItem();

                        string testType = t.TestTypeName;
                        //string errorString = (string)this.GetOnErrorCollection()[t.OnErrorValue];
                        //string successString = (string)this.GetOnSuccessCollection()[t.OnSuccessValue];
                        lv.Text = t.Name;
                        lv.SubItems.Add(testType);

                        // TODO: Populate
                        lstTestManager.Items.Add(lv);
                    }
                }
            }
        }
Ejemplo n.º 40
0
 public TestPassed()
 {
     TestCase = new TestCase();
     TestCollection = new TestCollection();
 }
Ejemplo n.º 41
0
 public static void Main(string[] args)
 {
     var test = new TestCollection<string> ();
     test.Add ("Hello World");
     Console.WriteLine (test [0]);
 }
Ejemplo n.º 42
0
 public TestSkipped()
 {
     TestCase = new TestCase();
     TestCollection = new TestCollection();
     Output = String.Empty;
 }
Ejemplo n.º 43
0
		/// <summary>
		/// Removes the target namespace and all parent namespaces that are empty after the removal.
		/// </summary>
		static void RemoveTestNamespace(TestCollection collection, string parentNamespace, string @namespace)
		{
			if (parentNamespace == @namespace)
				return;
			foreach (var node in collection.OfType<TestNamespace>()) {
				if (@namespace == node.NamespaceName) {
					collection.Remove(node);
					return;
				}
				if (@namespace.StartsWith(node.NamespaceName + ".", StringComparison.Ordinal)) {
					RemoveTestNamespace(node.NestedTests, node.NamespaceName, @namespace);
					if (node.NestedTests.Count == 0) {
						collection.Remove(node);
					}
					return;
				}
			}
		}
Ejemplo n.º 44
0
		static TestCollection FindNamespace(TestCollection collection, string parentNamespace, string @namespace)
		{
			if (parentNamespace == @namespace)
				return collection;
			foreach (var node in collection.OfType<TestNamespace>()) {
				if (@namespace == node.NamespaceName)
					return node.NestedTests;
				if (@namespace.StartsWith(node.NamespaceName + ".", StringComparison.Ordinal)) {
					return FindNamespace(node.NestedTests, node.NamespaceName, @namespace);
				}
			}
			return null;
		}
Ejemplo n.º 45
0
		TestCollection FindOrCreateNamespace(TestCollection collection, string parentNamespace, string @namespace)
		{
			if (parentNamespace == @namespace)
				return collection;
			foreach (var node in collection.OfType<TestNamespace>()) {
				if (@namespace == node.NamespaceName)
					return node.NestedTests;
				if (@namespace.StartsWith(node.NamespaceName + ".", StringComparison.Ordinal)) {
					return FindOrCreateNamespace(node.NestedTests, node.NamespaceName, @namespace);
				}
			}
			// Create missing namespace node:
			
			// Figure out which part of the namespace we can remove due to the parent namespace:
			int startPos = 0;
			if (@namespace.StartsWith(parentNamespace + ".", StringComparison.Ordinal)) {
				startPos = parentNamespace.Length + 1;
			}
			// Get the next dot
			int dotPos = @namespace.IndexOf('.', startPos);
			if (dotPos < 0) {
				var newNode = new TestNamespace(this, @namespace);
				collection.Add(newNode);
				return newNode.NestedTests;
			} else {
				var newNode = new TestNamespace(this, @namespace.Substring(0, dotPos));
				collection.Add(newNode);
				return FindOrCreateNamespace(newNode.NestedTests, newNode.NamespaceName, @namespace);
			}
		}
Ejemplo n.º 46
0
 public TestSkipped()
 {
     TestCase = new TestCase();
     TestCollection = new TestCollection();
 }
Ejemplo n.º 47
0
		public void EnsureNestedTestsInitialized()
		{
			if (nestedTests == null) {
				nestedTests = InitializeNestedTests();
				OnNestedTestsInitialized();
			}
		}