public void ConstructorSetsSkipStackFramesCorrectly() { var expectedSkipStackFrames = 123; var sut = new DataDrivenTest(expectedSkipStackFrames); Assert.AreEqual(expectedSkipStackFrames, sut.SkipStackFrames); }
public void ArrangeWithNoArgumentsSetsTestCaseCorrectly() { var sut = new DataDrivenTest().Arrange(); Assert.AreEqual(1, sut.TestCases.Count, "There should only be a single test case"); Assert.AreEqual(0, sut.TestCaseArgumentCount, "The test case should not have any arguments"); Assert.AreEqual(0, sut.TestCases.First().Length, "There should not be any arguments in the first test case"); }
public void ArrangeFromAttributesSetsTestCaseCorrectly() { var sut = new DataDrivenTest().ArrangeFromAttributes(); Assert.AreEqual(1, sut.TestCases.Count, "There should only be a single test case"); Assert.AreEqual(1, sut.TestCaseArgumentCount, "The test case should only have one argument"); Assert.AreEqual("test", sut.TestCases.First().First(), "Incorrect argument value"); }
public void ArrangeSetsTestCasesCorrectly() { var sut = new DataDrivenTest() .Arrange("test", "case") .Arrange("test 2", "case 2") .Arrange("test 3", "case 3"); Assert.AreEqual(3, sut.TestCases.Count, "There should be three test cases"); Assert.AreEqual(2, sut.TestCaseArgumentCount, "Each test case should have two arguments"); Assert.AreEqual("case 2", sut.TestCases.ElementAt(1)[1], "Incorrect value in the second argument of the second test case"); }
public void ArrangeFuncSetsTestCaseCorrectly() { Func <IEnumerable <object> > expected = () => new List <object> { "test", "case" }; var sut = new DataDrivenTest().Arrange(expected); Assert.AreEqual(1, sut.TestCases.Count, "There should only be a single test case"); Assert.AreEqual(2, sut.TestCaseArgumentCount, "The test case should have two arguments"); Assert.AreEqual("test", sut.TestCases.First().First(), "Incorrect value of the first argument"); }
/// <summary> /// Runs a client test with both Atom and Json OData formats. /// </summary> /// <typeparam name="TContext">The DataServiceContext type.</typeparam> /// <param name="testBase">The test class running the test.</param> /// <param name="createContext">A delegate to create the context.</param> /// <param name="test">The test action to execute.</param> public static void RunOnAtomAndJsonFormats <TContext>( this EndToEndTestBase testBase, Func <DataServiceContextWrapper <TContext> > createContext, Action <DataServiceContextWrapper <TContext> > test) where TContext : DataServiceContext { var jsonContext = createContext(); jsonContext.ContextLabel = "Json"; jsonContext.Format.UseJson(); testBase.InvokeDataDrivenTest(test, DataDrivenTest.CreateData(jsonContext)); }
public void ActAndAssertThrowsWhenNoTestCasesHaveBeenArranged() { var expected = "Assert.Fail failed. There are no test cases. Have you forgotten to arrange them?"; try { var sut = new DataDrivenTest(); sut.ActAndAssert((object x) => { }); } catch (AssertFailedException ex) { Assert.AreEqual(expected, ex.Message); } }
public void ActAndAssertIsCalledCorrectly() { var sut = new DataDrivenTest() .Arrange("test 0", "case 0") .Arrange("test 1", "case 1"); var actualCallCount = 0; var act = new Action <string, string>((test, expected) => { Assert.AreEqual(test, $"test {actualCallCount}"); Assert.AreEqual(expected, $"case {actualCallCount}"); actualCallCount++; }); sut.ActAndAssert(act); Assert.AreEqual(2, actualCallCount, "Act should be called twice"); }
public void ArrangeTestCasesFuncSetsTestCasesCorrectly() { Func <IEnumerable <IEnumerable <object> > > expected = () => new List <List <object> > { new List <object> { "test", "case" }, new List <object> { "test 2", "case 2" }, new List <object> { "test 3", "case 3" } }; var sut = new DataDrivenTest().ArrangeTestCases(expected); Assert.AreEqual(3, sut.TestCases.Count, "There should be three test cases"); Assert.AreEqual(2, sut.TestCaseArgumentCount, "Each test case should have two arguments"); Assert.AreEqual("case 2", sut.TestCases.ElementAt(1)[1], "Incorrect value in the second argument of the second test case"); }
public void ActAndAssertThrowsWhenActAndAssertDelegateIsNull() { var sut = new DataDrivenTest(); sut.ActAndAssert(null); }
public void ActAndAssertThrows() { var sut = new DataDrivenTest().Arrange("testcase"); sut.ActAndAssert((string x) => { throw new InvalidOperationException(); }); }
public void EmptyConstructorSetsSkipStackFramesCorrectly() { var sut = new DataDrivenTest(); Assert.AreEqual(1, sut.SkipStackFrames); }
/// <summary> /// To data driven parameter data /// </summary> /// <typeparam name="T">The item type</typeparam> /// <param name="collection">The item collecion</param> /// <returns>The parameter data</returns> public static ParameterData<T> ToParamData<T>(this IEnumerable<T> collection) { return DataDrivenTest.CreateData(collection.ToArray()); }