public bool IsOnPathTo(TestPosition testPosition) { var thisCoordinateCount = this.Coordinates.Count(); if (thisCoordinateCount > testPosition.Coordinates.Count()) { return(false); } for (var i = 0; i < thisCoordinateCount; i++) { int thisCoordinate = this.Coordinates.Skip(i).First(); int testCoordinate = testPosition.Coordinates.Skip(i).First(); if (thisCoordinate != testCoordinate) { if (i == thisCoordinateCount - 1) { return(thisCoordinate <= testCoordinate); } else { return(false); } } } return(true); }
private void RecordTestAt(Func<SpecificationFixture> fixtureFactory, TestPosition testPosition, GenericNativeTest result) { if (!TestAt.ContainsKey(fixtureFactory)) TestAt[fixtureFactory] = new Dictionary<TestPosition, GenericNativeTest>(); TestAt[fixtureFactory][testPosition] = result; }
public NJasmineInvalidTestSuite(Exception e, TestPosition position) : base(((Action)delegate() { }).Method) { _reason = e.Message; _stackTrace = e.StackTrace; Position = position; }
public NJasmineTestSuiteNUnit(string parentSuiteName, string name, Action oneTimeTeardown, TestPosition position) : base(parentSuiteName, name) { _oneTimeTeardown = oneTimeTeardown; maintainTestOrder = true; Position = position; }
public NJasmineTestSuite(TestPosition position, GlobalSetupManager setupManager) : base("thistestname", "willbeoverwritten") { Position = position; _setupManager = setupManager; maintainTestOrder = true; }
public NJasmineTestMethod(Func<SpecificationFixture> fixtureFactory, TestPosition position, IGlobalSetupManager globalSetup) : base(new Action(delegate() { }).Method) { Position = position; _fixtureFactory = fixtureFactory; _globalSetup = globalSetup; }
public bool IsAncestorOf(TestPosition position) { if (Coordinates.Count() < position.Coordinates.Count()) { return (position.Coordinates.Take(Coordinates.Count()).SequenceEqual(Coordinates)); } return false; }
private void RecordTestAt(Func <SpecificationFixture> fixtureFactory, TestPosition testPosition, GenericNativeTest result) { if (!TestAt.ContainsKey(fixtureFactory)) { TestAt[fixtureFactory] = new Dictionary <TestPosition, GenericNativeTest>(); } TestAt[fixtureFactory][testPosition] = result; }
public void test_IsAncestorOf() { var position = new TestPosition(1, 2, 3); expect(() => position.IsAncestorOf(new TestPosition(1, 2, 3, 4))); expect(() => position.IsAncestorOf(new TestPosition(1, 2, 3, 4, 0, 1, 2))); expect(() => !position.IsAncestorOf(new TestPosition(1, 2))); expect(() => !position.IsAncestorOf(new TestPosition(3, 2, 1, 4))); }
public bool IsAncestorOf(TestPosition position) { if (Coordinates.Count() < position.Coordinates.Count()) { return(position.Coordinates.Take(Coordinates.Count()).SequenceEqual(Coordinates)); } return(false); }
public bool Equals(TestPosition other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(other.ToString().Equals(this.ToString())); }
public static TestResultShim RunTest(TestContext testContext, List <string> traceMessages) { var startTime = DateTime.UtcNow; var testResult = new TestResultShim(); Exception existingError = testContext.FixtureContext.GlobalSetupManager.PrepareForTestPosition(testContext.Position); if (existingError != null) { TestResultUtil.Error(testResult, testContext.Name.MultilineName, existingError, null, TestResultShim.Site.SetUp); } else { traceMessages.AddRange(testContext.FixtureContext.GlobalSetupManager.GetTraceMessages()); try { List <string> traceMessages1 = traceMessages; traceMessages1 = traceMessages1 ?? new List <string>(); var executionContext = new NJasmineTestRunContext(testContext.Position, testContext.FixtureContext.GlobalSetupManager, traceMessages1); var runner = new NJasmineTestRunner(executionContext); SpecificationFixture fixture = testContext.FixtureContext.FixtureFactory(); fixture.CurrentPosition = TestPosition.At(0); fixture.Visitor = runner; try { fixture.Run(); } finally { executionContext.RunAllPerTestTeardowns(); } testResult.Success(); } catch (Exception e) { TestResultUtil.Error(testResult, testContext.Name.MultilineName, e, traceMessages); } } testResult.SetExecutionTime(DateTime.UtcNow - startTime); return(testResult); }
public void can_be_used_with_dictionaries() { var position1 = new TestPosition(1, 2, 3); var position2 = new TestPosition(4, 5, 6); var position3 = new TestPosition(7, 8, 9); expect(() => position1.Equals(new TestPosition(1, 2, 3))); Dictionary<TestPosition, int> dictionary = new Dictionary<TestPosition, int>(); dictionary[position1] = 1; dictionary[position2] = 2; dictionary[position3] = 3; expect(() => dictionary[new TestPosition(1,2,3)] == 1); expect(() => dictionary[new TestPosition(4,5,6)] == 2); expect(() => dictionary[new TestPosition(7, 8, 9)] == 3); }
public static void BuildTestFixture(Type type, INativeTestFactory nativeTestFactory, GlobalSetupOwner globalSetupOwner) { if (nativeTestFactory is ValidatingNativeTestFactory) { throw new InvalidOperationException("Do not pass a ValidatingNativeTestFactory here."); } nativeTestFactory = new ValidatingNativeTestFactory(nativeTestFactory); var constructor = type.GetConstructor(new Type[0]); Func <SpecificationFixture> fixtureFactory = delegate() { var fixture = constructor.Invoke(new object[0]) as SpecificationFixture; return(fixture); }; var setupManager = globalSetupOwner.GetSetupManager(type, fixtureFactory); FixtureContext fixtureContext = new FixtureContext(nativeTestFactory, fixtureFactory, new NameReservations(), setupManager); var testContext = new TestContext() { Position = TestPosition.At(), FixtureContext = fixtureContext, Name = new TestName { FullName = type.Namespace + "." + type.Name, Shortname = type.Name, MultilineName = type.Namespace + "." + type.Name } }; var explicitReason = ExplicitAttributeReader.GetFor(type); var result = BuildSuiteForTextContext(fixtureContext, testContext, fixtureContext.GetSpecificationRootAction(), true, explicitReason); nativeTestFactory.SetRoot(result); }
public bool Equals(TestPosition other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return other.ToString().Equals(this.ToString()); }
public INativeTestBuilder ForTest(Func<SpecificationFixture> fixtureFactory, TestPosition position, GlobalSetupManager globalSetupManager) { var result = new NativeTest(new NJasmineTestMethod(fixtureFactory, position, globalSetupManager)); return result; }
public INativeTestBuilder ForUnimplementedTest(TestPosition position) { var result = new NativeTest(new NJasmineUnimplementedTestMethod(position)); return result; }
public INativeTestBuilder ForFailingSuite(TestPosition position, Exception exception) { return new NativeTest(new NJasmineInvalidTestSuite(exception, position)); }
public INativeTestBuilder ForSuite(TestPosition position, Action onetimeCleanup) { var result = new NativeTest(new NJasmineTestSuiteNUnit("hi", "there", onetimeCleanup, position)); return result; }
public void test_Parent() { var position = new TestPosition(1, 2, 3); expect(() => position.Parent.Equals(new TestPosition(1, 2))); }
public NJasmineTestSuite(INativeTestFactory nativeTestFactory, TestPosition position, GlobalSetupManager globalSetup) { _nativeTestFactory = nativeTestFactory; _position = position; _globalSetup = globalSetup; }
public NJasmineNUnitTestMethod(MethodInfo method, TestPosition position) : base(method) { Position = position; }
void expect_test_to_observe(TestPosition testPosition, List<string> expected) { var fixture = new has_test_in_loop(); var method = new NJasmine.Core.NJasmineTestMethod(() => fixture, testPosition, new FakeGlobalSetupManager()); TestResult result = new TestResult(method); List<string> ignored; method.RunTestMethod(result, out ignored); expect(() => result.IsSuccess); Assert.That(fixture.Observations, Is.EquivalentTo(expected)); }
public bool IsOnPathTo(TestPosition testPosition) { var thisCoordinateCount = this.Coordinates.Count(); if (thisCoordinateCount > testPosition.Coordinates.Count()) return false; for(var i = 0; i < thisCoordinateCount; i++) { int thisCoordinate = this.Coordinates.Skip(i).First(); int testCoordinate = testPosition.Coordinates.Skip(i).First(); if (thisCoordinate != testCoordinate) { if (i == thisCoordinateCount - 1) return thisCoordinate <= testCoordinate; else return false; } } return true; }
public NJasmineUnimplementedTestMethod(TestPosition position) : base(((Action)delegate() { }).Method, position) { }
void expect_test_to_observe(TestPosition testPosition, List<string> expected) { var fixture = new has_test_in_loop(); var traceMessages = new List<string>(); SpecificationRunner.RunTest(new TestContext() { FixtureContext = new FixtureContext(null, () => fixture, null, new FakeGlobalSetupManager()), Name = new TestName(), Position = testPosition }, traceMessages); Assert.That(fixture.Observations, Is.EquivalentTo(expected)); }