예제 #1
0
        public void RunTestMethodShouldReturnParentResultForDataRowDataDrivenTestsContainingSingleTest()
        {
            UTF.TestResult testResult = new UTF.TestResult
            {
                ResultFiles = new List <string>()
                {
                    "C:\\temp.txt"
                }
            };

            var testMethodInfo   = new TestableTestmethodInfo(this.methodInfo, this.testClassInfo, this.testMethodOptions, () => testResult);
            var testMethodRunner = new TestMethodRunner(testMethodInfo, this.testMethod, this.testContextImplementation, false, this.mockReflectHelper.Object);

            int dummyIntData1 = 1;

            UTF.DataRowAttribute dataRowAttribute1 = new UTF.DataRowAttribute(dummyIntData1);

            var attribs = new Attribute[] { dataRowAttribute1 };

            // Setup mocks
            this.testablePlatformServiceProvider.MockReflectionOperations.Setup(rf => rf.GetCustomAttributes(this.methodInfo, It.IsAny <Type>(), It.IsAny <bool>())).Returns(attribs);

            var results = testMethodRunner.RunTestMethod();

            CollectionAssert.Contains(results[1].ResultFiles.ToList(), "C:\\temp.txt");

            // Parent result should exist.
            Assert.AreEqual(2, results.Length);
            Assert.AreEqual(results[0].ExecutionId, results[1].ParentExecId);
            Assert.AreEqual(Guid.Empty, results[0].ParentExecId);
            Assert.AreNotEqual(Guid.Empty, results[1].ParentExecId);
        }
예제 #2
0
        public void ExecuteShouldStartTheActionOnANewThread()
        {
            int    actionThreadID = 0;
            Action action         = () => { actionThreadID = Thread.CurrentThread.ManagedThreadId; };

            Assert.IsTrue(this.asyncOperations.Execute(action, 1000));

            Assert.AreNotEqual(Thread.CurrentThread.ManagedThreadId, actionThreadID);
        }
        public void ExecuteShouldRunActionOnANewThread()
        {
            int actionThreadID          = 0;
            var cancellationTokenSource = new CancellationTokenSource();

            void action()
            {
                actionThreadID = Thread.CurrentThread.ManagedThreadId;
            }

            Assert.IsTrue(this.asyncOperations.Execute(action, 1000, cancellationTokenSource.Token));
            Assert.AreNotEqual(Thread.CurrentThread.ManagedThreadId, actionThreadID);
        }
예제 #4
0
        public void GetNavigationDataShouldReturnDataFromNavigationSession()
        {
            var diaSession = this.fileOperations.CreateNavigationSession(Assembly.GetExecutingAssembly().Location);

            this.fileOperations.GetNavigationData(
                diaSession,
                typeof(DesktopFileOperationsTests).FullName,
                "GetNavigationDataShouldReturnDataFromNavigationSession",
                out var minLineNumber,
                out var fileName);

            Assert.AreNotEqual(-1, minLineNumber);
            Assert.IsNotNull(fileName);
        }
예제 #5
0
        public void RunTestMethodShouldSetParentResultOutcomeProperlyForDataRowDataDrivenTests()
        {
            var testExecutedCount = 0;
            var testMethodInfo    = new TestableTestmethodInfo(this.methodInfo, this.testClassInfo, this.testMethodOptions, () =>
            {
                return((testExecutedCount++ == 0) ?
                       new UTF.TestResult {
                    Outcome = UTF.UnitTestOutcome.Failed
                } :
                       new UTF.TestResult {
                    Outcome = UTF.UnitTestOutcome.Passed
                });
            });
            var testMethodRunner = new TestMethodRunner(testMethodInfo, this.testMethod, this.testContextImplementation, false, this.mockReflectHelper.Object);

            int dummyIntData1 = 1;
            int dummyIntData2 = 2;

            UTF.DataRowAttribute dataRowAttribute1 = new UTF.DataRowAttribute(dummyIntData1);
            UTF.DataRowAttribute dataRowAttribute2 = new UTF.DataRowAttribute(dummyIntData2);

            var attribs = new Attribute[] { dataRowAttribute1, dataRowAttribute2 };

            // Setup mocks
            this.testablePlatformServiceProvider.MockReflectionOperations.Setup(rf => rf.GetCustomAttributes(this.methodInfo, It.IsAny <Type>(), It.IsAny <bool>())).Returns(attribs);

            var results = testMethodRunner.RunTestMethod();

            // Parent result should exist.
            Assert.AreEqual(3, results.Length);
            Assert.AreEqual(results[0].ExecutionId, results[1].ParentExecId);
            Assert.AreEqual(results[0].ExecutionId, results[2].ParentExecId);
            Assert.AreEqual(Guid.Empty, results[0].ParentExecId);
            Assert.AreNotEqual(Guid.Empty, results[1].ParentExecId);
            Assert.AreNotEqual(Guid.Empty, results[2].ParentExecId);

            // Check for aggregate outcome.
            Assert.AreEqual(AdapterTestOutcome.Failed, results[0].Outcome);
            Assert.AreEqual(AdapterTestOutcome.Failed, results[1].Outcome);
            Assert.AreEqual(AdapterTestOutcome.Passed, results[2].Outcome);
        }
        public void CreateInstanceForTypeShouldCreateTheTypeInANewAppDomain()
        {
            // Setup
            DummyClass dummyclass         = new DummyClass();
            int        currentAppDomainId = dummyclass.AppDomainId;

            TestSourceHost sut = new TestSourceHost(Assembly.GetExecutingAssembly().Location, null, null);

            // Execute
            var expectedObject = sut.CreateInstanceForType(typeof(DummyClass), null) as DummyClass;

            int newAppDomainId = currentAppDomainId + 10;  // not equal to currentAppDomainId

            if (expectedObject != null)
            {
                newAppDomainId = expectedObject.AppDomainId;
            }

            // Assert
            Assert.AreNotEqual(currentAppDomainId, newAppDomainId);
        }
예제 #7
0
        public void RunTestMethodShouldReturnParentResultForDataSourceDataDrivenTestsContainingSingleTest()
        {
            var testMethodInfo   = new TestableTestmethodInfo(this.methodInfo, this.testClassInfo, this.testMethodOptions, () => new UTF.TestResult());
            var testMethodRunner = new TestMethodRunner(testMethodInfo, this.testMethod, this.testContextImplementation, false);

            UTF.DataSourceAttribute dataSourceAttribute = new UTF.DataSourceAttribute("DummyConnectionString", "DummyTableName");

            var attribs = new Attribute[] { dataSourceAttribute };

            // Setup mocks
            this.testablePlatformServiceProvider.MockReflectionOperations.Setup(rf => rf.GetCustomAttributes(this.methodInfo, It.IsAny <Type>(), It.IsAny <bool>())).Returns(attribs);
            this.testablePlatformServiceProvider.MockTestDataSource.Setup(tds => tds.GetData(testMethodInfo, this.testContextImplementation)).Returns(new object[] { 1 });

            var results = testMethodRunner.RunTestMethod();

            // Parent result should exist.
            Assert.AreEqual(2, results.Length);
            Assert.AreEqual(results[0].ExecutionId, results[1].ParentExecId);
            Assert.AreEqual(Guid.Empty, results[0].ParentExecId);
            Assert.AreNotEqual(Guid.Empty, results[1].ParentExecId);
        }
예제 #8
0
        public void RunTestMethodShouldSetParentResultOutcomeProperlyForDataSourceDataDrivenTests()
        {
            var testExecutedCount = 0;
            var testMethodInfo    = new TestableTestmethodInfo(this.methodInfo, this.testClassInfo, this.testMethodOptions, () =>
            {
                return((testExecutedCount++ == 0) ?
                       new UTF.TestResult {
                    Outcome = UTF.UnitTestOutcome.Failed
                } :
                       new UTF.TestResult {
                    Outcome = UTF.UnitTestOutcome.Passed
                });
            });
            var testMethodRunner = new TestMethodRunner(testMethodInfo, this.testMethod, this.testContextImplementation, false);

            UTF.DataSourceAttribute dataSourceAttribute = new UTF.DataSourceAttribute("DummyConnectionString", "DummyTableName");

            var attribs = new Attribute[] { dataSourceAttribute };

            // Setup mocks
            this.testablePlatformServiceProvider.MockReflectionOperations.Setup(rf => rf.GetCustomAttributes(this.methodInfo, It.IsAny <Type>(), It.IsAny <bool>())).Returns(attribs);
            this.testablePlatformServiceProvider.MockTestDataSource.Setup(tds => tds.GetData(testMethodInfo, this.testContextImplementation)).Returns(new object[] { 1, 2, 3 });

            var results = testMethodRunner.RunTestMethod();

            // check for parent result
            Assert.AreEqual(4, results.Length);
            Assert.AreEqual(results[0].ExecutionId, results[1].ParentExecId);
            Assert.AreEqual(Guid.Empty, results[0].ParentExecId);
            Assert.AreNotEqual(Guid.Empty, results[1].ParentExecId);

            // Check for aggregate outcome.
            Assert.AreEqual(AdapterTestOutcome.Failed, results[0].Outcome);
            Assert.AreEqual(AdapterTestOutcome.Failed, results[1].Outcome);
            Assert.AreEqual(AdapterTestOutcome.Passed, results[2].Outcome);
            Assert.AreEqual(AdapterTestOutcome.Passed, results[3].Outcome);
        }