Exemplo n.º 1
0
        public async Task RunTest_ByUniqueName()
        {
            // Arrange
            var host = new TestHostWrapper(_testProject);

            await host.StartAsync();

            await host.ListTestsAsync();

            var test = host.Output
                       .Where(m => m.MessageType == "TestDiscovery.TestFound")
                       .First()
                       .Payload.ToObject <Test>();

            host.Output.Clear();

            host = new TestHostWrapper(_testProject);
            await host.StartAsync();

            // Act
            var result = await host.RunTestsAsync(_testProject, test.FullyQualifiedName);

            // Assert
            Assert.Equal(0, result);

            Assert.Equal(3, host.Output.Count);
            Assert.Single(host.Output, m => TestStarted(m, test.DisplayName));
            Assert.Single(host.Output, m => TestPassed(m, test.DisplayName));
            Assert.Equal("TestExecution.Response", host.Output[host.Output.Count - 1].MessageType);
        }
Exemplo n.º 2
0
        private void ExecuteDiscoverTests(object _)
        {
            try
            {
                Status = "Discovering Tests...";

                var timer = Stopwatch.StartNew();
                var task  = _host.ListTestsAsync();

                task.ContinueWith(t =>
                {
                    if (t.IsFaulted)
                    {
                        Status = "Discovering Tests failed.";
                        ShowErrorDialog(t.Exception);
                    }
                    else
                    {
                        Status = string.Format("Discovered Tests in {0}ms", timer.ElapsedMilliseconds);
                    }

                    Reset();
                }, _scheduler);
            }
            catch (Exception ex)
            {
                ShowErrorDialog(ex);
                Reset();
            }
        }
Exemplo n.º 3
0
        public async Task ListTest_InheritedMethod_Symbols()
        {
            // Arrange
            var host = new TestHostWrapper(_testProject);

            await host.StartAsync();

            // Act
            var result = await host.ListTestsAsync();

            // Assert
            Assert.Equal(0, result);

            var test = GetTest(host.Output, "DerivedTest.ThisGetsInherited");

            Assert.NotNull(test);

            Assert.EndsWith("BaseTest.cs", test.CodeFilePath);
            Assert.Equal(12, test.LineNumber);
        }
Exemplo n.º 4
0
        public async Task ListTest_AsyncMethod_Symbols()
        {
            // Arrange
            var host = new TestHostWrapper(_testProject);

            await host.StartAsync();

            // Act
            var result = await host.ListTestsAsync();

            // Assert
            Assert.Equal(0, result);

            var test = GetTest(host.Output, "SampleTest.SampleAsyncTest");

            Assert.NotNull(test);

            Assert.EndsWith("SampleTest.cs", test.CodeFilePath);
            Assert.Equal(35, test.LineNumber);
        }
Exemplo n.º 5
0
        public async Task ListTest()
        {
            // Arrange
            var host = new TestHostWrapper(_testProject);

            await host.StartAsync();

            // Act
            var result = await host.ListTestsAsync();

            // Assert
            Assert.Equal(0, result);

            /* Following message will be sent when test is running in an environment missing DIA.
             * Should it exists, it will be extracted from the message list.
             * {
             *     "Name": "Microsoft.Dnx.TestHost.TestAdapter.SourceInformationProvider",
             *     "EventId": 0,
             *     "Level": "Warning",
             *     "Message": "Failed to create DIA DataSource. No source information will be available.\r\nSystem.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {E6756135-1E65-4D17-8576-610761398C3C} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).\r\n   at Microsoft.Framework.TestHost.TestAdapter.SourceInformationProvider.EnsureInitialized() in C:\\projects\\testing\\src\\Microsoft.Dnx.TestHost\\TestAdapter\\SourceInformationProvider.cs:line 155"
             */

            var fullMessageDiagnostics = string.Format("Full output: \n{0}", string.Join("\n", host.Output));
            var testOutput             = host.Output.Where(message => message.MessageType != "Log");

            Assert.True(10 == testOutput.Count(), "Number of messages is not right. \n" + fullMessageDiagnostics);
            Assert.Single(host.Output, m => TestFound(m, "SampleTest.True_is_true"));
            Assert.Single(host.Output, m => TestFound(m, "SampleTest.TheoryTest1(x: 1)"));
            Assert.Single(host.Output, m => TestFound(m, "SampleTest.TheoryTest1(x: 2)"));
            Assert.Single(host.Output, m => TestFound(m, "SampleTest.TheoryTest1(x: 3)"));
            Assert.Single(host.Output, m => TestFound(m, "SampleTest.TheoryTest2(x: 1, s: \"Hi\")"));
            Assert.Single(host.Output, m => TestFound(m, "SampleTest.TheoryTest2(x: 2, s: \"Hi\")"));
            Assert.Single(host.Output, m => TestFound(m, "SampleTest.TheoryTest2(x: 3, s: \"Hi\")"));
            Assert.Single(host.Output, m => TestFound(m, "SampleTest.SampleAsyncTest"));
            Assert.Single(host.Output, m => TestFound(m, "DerivedTest.ThisGetsInherited"));
            Assert.Equal("TestDiscovery.Response", host.Output[host.Output.Count - 1].MessageType);
        }