public TestContext CreateContext (TestFixture fixture) { var instance = Activator.CreateInstance (fixture.Type); var context = new SimpleTestContext (fixture, instance); return context; }
public void StaticMethodAsProvider() { var tf = new TestFixture(typeof(FixtureWithStaticDataProvider)); tf.Execute(new TestRun(new AllTestsCriterion()), new SimpleTestListener()); Assert.Equals(4, SimpleTestListener.PassedItems.Count); Assert.Equals(0, SimpleTestListener.ErrorItems.Count); Assert.Equals(" TS:Squares TP:Squares TS:Squares TP:Squares TS:Squares TP:Squares TS:Squares TP:Squares", SimpleTestListener.Messages); }
public void ExecuteMethodThrowsException() { var fixture = new TestFixture(typeof(Foo)); var tm = new TestMethod(fixture, typeof(Foo).GetMethod("MethodWithException")); tm.Execute(_listener); Assert.Equals(" MethodWithException", _sequence); Assert.StartsWith(" TS:MethodWithException TE:MethodWithException ", SimpleTestListener.Messages); }
public void ExecuteMethod() { var fixture = new TestFixture(typeof(Foo)); var tm = new TestMethod(fixture, typeof(Foo).GetMethod("AMethod")); tm.Execute( _listener); Assert.Equals(" AMethod", _sequence); Assert.Equals(" TS:AMethod TP:AMethod", SimpleTestListener.Messages); }
public void EmptySimpleList() { var tf = new TestFixture(typeof(ClassWithEmptyList)); tf.Execute(new TestRun(new AllTestsCriterion()), new SimpleTestListener()); Assert.Equals(0, SimpleTestListener.PassedItems.Count); Assert.Equals(1, SimpleTestListener.ErrorItems.Count); Assert.Contains(" TE:SimpleTest No data rows specified for parameterized test.", SimpleTestListener.Messages); }
public void SetUp() { const string sql = "create table Album (" + "Id nvarchar(255) not null primary key, " + "Data ntext not null)"; _fixture = new TestFixture(sql, "Album"); }
public void SettingNoCategorySelectsAll() { var fixture = new TestFixture(typeof(Foo)); var theTests = new MultipleTestsCriterion(); theTests.Add(typeof(Foo).Assembly.FullName, typeof(Foo).FullName, string.Empty); fixture.Execute(new TestRun(theTests), new NullListener()); Assert.Equals("#Foo.Bar#Foo.GreenFunc", Foo._messages); }
public void TestSetterBinding() { var f = new TestFixture { Processor = new Service.Service()}; BindingOperation bindingOperation = new InputBinding(f.CellOperation, f, TestUtils.CreateCell("sampleInt")); bindingOperation.Do(MakeCell("123456")); Assert.AreEqual(123456, f.sampleInt); bindingOperation.Do(MakeCell("-234567")); Assert.AreEqual(-234567, f.sampleInt); bindingOperation = new InputBinding(f.CellOperation, f, TestUtils.CreateCell("sampleDouble")); bindingOperation.Do(MakeCell("3.14159")); Assert.AreEqual(3.14159, f.sampleDouble); bindingOperation = new InputBinding(f.CellOperation, f, TestUtils.CreateCell("sampleChar")); bindingOperation.Do(MakeCell("a")); Assert.AreEqual('a', f.sampleChar); bindingOperation = new InputBinding(f.CellOperation, f, TestUtils.CreateCell("sampleString")); bindingOperation.Do(MakeCell("xyzzy")); Assert.AreEqual("xyzzy", f.sampleString); bindingOperation = new InputBinding(f.CellOperation, f, TestUtils.CreateCell("sampleFloat")); bindingOperation.Do(MakeCell("6.02e23")); Assert.AreEqual(6.02e23f, f.sampleFloat, 1e17f); bindingOperation = new InputBinding(f.CellOperation, f, TestUtils.CreateCell("sampleByte")); bindingOperation.Do(MakeCell("123")); Assert.AreEqual(123, f.sampleByte); bindingOperation = new InputBinding(f.CellOperation, f, TestUtils.CreateCell("sampleShort")); bindingOperation.Do(MakeCell("12345")); Assert.AreEqual(12345, f.sampleShort); }
public TestContext CreateContext (TestFixture fixture) { var instance = Activator.CreateInstance (fixture.Type); var context = new HttpClientTestContext (fixture, instance); context.Handler = extension.CreateHandler (); context.Client = new HttpClient (context.Handler, true); return context; }
public void ASimpleListWithError() { var tf = new TestFixture(typeof(FixtureWithErrorInList)); tf.Execute(new TestRun(new AllTestsCriterion()), new SimpleTestListener()); Assert.Equals(1, SimpleTestListener.PassedItems.Count); Assert.Equals(1, SimpleTestListener.ErrorItems.Count); Assert.Contains(" TS:SimpleTest TP:SimpleTest", SimpleTestListener.Messages); Assert.Contains(" TE:SimpleTest Each data row for SimpleTest must have 2 values.", SimpleTestListener.Messages); }
public void ExecuteSelectedCategoryOnly() { var fixture = new TestFixture(typeof(Foo)); var theTests = new MultipleTestsCriterion(); theTests.Add(typeof(Foo).Assembly.FullName, typeof(Foo).FullName, string.Empty); var testRun = TestRun.Where(theTests).And(new CategoryCriterion("Green")); fixture.Execute(testRun, new NullListener()); Assert.Equals("#Foo.GreenFunc", Foo._messages); }
// ReSharper disable UnusedMember.Global public void SetUp() { // ReSharper restore UnusedMember.Global _sequence = string.Empty; _listener = new SimpleTestListener(); _methodSequence = string.Empty; _tc = new TestFixture(typeof(ClassWithCategories)); RecipeFactory.Type = RecipeFactory.Default; }
public void WriteTo_with_content_should_output_expected_value(object content, string expectedOutput) { using (var wr = new StringWriter()) { var template = new TestFixture(f => f.WriteTo(wr, content)); template.Render(wr, new PageContext()); Assert.That(wr.ToString(), Is.EqualTo(expectedOutput)); } }
public void IgnoredMethod() { MyListener myListener = new MyListener(); TestFixture tc = new TestFixture(typeof(HasIgnoredMethod)); TestSpec ts = new TestSpec(); ts.AddTest("csUnit.Core.Tests", typeof(HasIgnoredMethod).FullName, string.Empty); tc.Execute(ts, myListener); Assert.Equals(1, myListener.SkipCount); // Skipped tests do not 'start' Assert.Equals(1, myListener.TestCount); }
public void Test_CreateObject_ShouldCreateUsingTestFactory() { //---------------Set up test pack------------------- TestFixture fixture = new TestFixture(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var fakeBO = fixture.CreateObject<FakeBO>(); //---------------Test Result ----------------------- Assert.IsNotNull(fakeBO); }
public ITestRunner[] GetTestRunners (TestFixture fixture) { var attr = fixture.Attribute as HttpClientTestFixtureAttribute; if (attr == null) return null; var list = new List<ITestRunner> (); if ((attr.Target & HttpClientTestTarget.Default) != 0) list.Add (defaultRunner); if ((attr.Target & HttpClientTestTarget.Custom) != 0) list.AddRange (extensionRunners); return list.ToArray (); }
public void Test_RegisterInstance_CreateShouldUseThisInstance() { //---------------Set up test pack------------------- TestFixture fixture = new TestFixture(); var expectedFakeBO = new FakeBO(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- fixture.Register(expectedFakeBO); var fakeBO = fixture.CreateObject<FakeBO>(); //---------------Test Result ----------------------- Assert.AreSame(expectedFakeBO, fakeBO); }
/// <summary> /// Build a TestFixture from type provided. A non-null TestSuite /// must always be returned, since the method is generally called /// because the user has marked the target class as a fixture. /// If something prevents the fixture from being used, it should /// be returned nonetheless, labelled as non-runnable. /// </summary> /// <param name="typeInfo">An ITypeInfo for the fixture to be used.</param> /// <returns>A TestSuite object or one derived from TestSuite.</returns> // TODO: This should really return a TestFixture, but that requires changes to the Test hierarchy. public TestSuite BuildFrom(ITypeInfo typeInfo) { var fixture = new TestFixture(typeInfo); if (fixture.RunState != RunState.NotRunnable) CheckTestFixtureIsValid(fixture); fixture.ApplyAttributesToTest(typeInfo.Type.GetTypeInfo()); AddTestCasesToFixture(fixture); return fixture; }
public ParameterizedTestMethod(TestFixture testFixture, MethodInfo methodInfo) : base(testFixture, methodInfo) { foreach(DataRow dataRow in methodInfo.GetCustomAttributes(typeof(DataRow), true)) { _dataSource.Add(dataRow); } if(_dataSource.Count == 0) { object[] attrs = methodInfo.GetCustomAttributes(typeof(DataSourceAttribute), true); if( attrs.Length > 0 ) { _dataSource.Add(attrs[0] as DataSourceAttribute); } } _expectedParameterNum = MethodInfo.GetParameters().Length; }
/// <summary> /// Build a TestFixture from type provided. A non-null TestSuite /// must always be returned, since the method is generally called /// because the user has marked the target class as a fixture. /// If something prevents the fixture from being used, it should /// be returned nonetheless, labelled as non-runnable. /// </summary> /// <param name="type">The type of the fixture to be used.</param> /// <returns>A TestSuite object or one derived from TestSuite.</returns> // TODO: This should really return a TestFixture, but that requires changes to the Test hierarchy. public TestSuite BuildFrom(Type type) { this.fixture = new TestFixture(type); if (fixture.RunState != RunState.NotRunnable) CheckTestFixtureIsValid(fixture); fixture.ApplyAttributesToTest(type); AddTestCases(type); return this.fixture; }
public void SetUp() { this.server = TestServer.Create<OwinStartup>(); var client = new HttpClient(new TraceMessageHandler(new ClientCompressionHandler(this.server.Handler, new GZipCompressor(), new DeflateCompressor()))) { BaseAddress = new Uri("http://localhost:55399") }; client.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip")); client.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("deflate")); this.testFixture = new TestFixture(client); }
public void PromoteNestedPropertyInsertedIntoColumn() { const string sql = "create table Album (" + "Id nvarchar(255) not null primary key, " + "Data ntext not null," + "ProducerName nvarchar(255))"; _fixture = new TestFixture(sql, "Album"); Configure.Promote<Album>(a => a.Producer.Name, "ProducerName"); var album = _fixture.GivenAValidAlbum(); _fixture.InsertDocument(album); var documentData = _fixture.GetDocumentDataById(album.Id); Assert.That(documentData["ProducerName"], Is.EqualTo(album.Producer.Name)); }
public void Setup() { var thread = new Thread(this.StartIISExpress) { IsBackground = true }; thread.Start(); var client = new HttpClient( new TraceMessageHandler(new ClientCompressionHandler(new GZipCompressor(), new DeflateCompressor()))) { BaseAddress = new Uri("http://localhost:55399") }; client.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip")); client.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("deflate")); this.testFixture = new TestFixture(client); }
public void MultiplePromotedProperties() { const string sql = "create table Album (" + "Id nvarchar(255) not null primary key, " + "Data ntext not null," + "ProducerName nvarchar(255)," + "Artist nvarchar(255))"; _fixture = new TestFixture(sql, "Album"); Configure.Promote<Album>(a => a.Producer.Name, "ProducerName"); Configure.Promote<Album>(a => a.Artist); var album = _fixture.GivenAValidAlbum(); _fixture.InsertDocument(album); Assert.That(_fixture.GetDocumentDataById(album.Id)["ProducerName"], Is.EqualTo(album.Producer.Name)); Assert.That(_fixture.GetDocumentDataById(album.Id)["Artist"], Is.EqualTo(album.Artist)); }
public void TestSetterBinding() { var f = new TestFixture { Processor = new Service.Service()}; BindingOperation bindingOperation = new InputBinding(f.CellOperation, f, TestUtils.CreateCell("sampleInt")); Parse p = new Parse("<table><tr><td>123456</td></tr></table>").Parts.Parts; bindingOperation.Do(null, p); Assert.AreEqual(123456, f.sampleInt); p = new Parse("<table><tr><td>-234567</td></tr></table>").Parts.Parts; bindingOperation.Do(null, p); Assert.AreEqual(-234567, f.sampleInt); bindingOperation = new InputBinding(f.CellOperation, f, TestUtils.CreateCell("sampleDouble")); p = new Parse("<table><tr><td>3.14159</td></tr></table>").Parts.Parts; bindingOperation.Do(null, p); Assert.AreEqual(3.14159, f.sampleDouble); bindingOperation = new InputBinding(f.CellOperation, f, TestUtils.CreateCell("sampleChar")); p = new Parse("<table><tr><td>a</td></tr></table>").Parts.Parts; bindingOperation.Do(null, p); Assert.AreEqual('a', f.sampleChar); bindingOperation = new InputBinding(f.CellOperation, f, TestUtils.CreateCell("sampleString")); p = new Parse("<table><tr><td>xyzzy</td></tr></table>").Parts.Parts; bindingOperation.Do(null, p); Assert.AreEqual("xyzzy", f.sampleString); bindingOperation = new InputBinding(f.CellOperation, f, TestUtils.CreateCell("sampleFloat")); p = new Parse("<table><tr><td>6.02e23</td></tr></table>").Parts.Parts; bindingOperation.Do(null, p); Assert.AreEqual(6.02e23f, f.sampleFloat, 1e17f); bindingOperation = new InputBinding(f.CellOperation, f, TestUtils.CreateCell("sampleByte")); p = new Parse("<table><tr><td>123</td></tr></table>").Parts.Parts; bindingOperation.Do(null, p); Assert.AreEqual(123, f.sampleByte); bindingOperation = new InputBinding(f.CellOperation, f, TestUtils.CreateCell("sampleShort")); p = new Parse("<table><tr><td>12345</td></tr></table>").Parts.Parts; bindingOperation.Do(null, p); Assert.AreEqual(12345, f.sampleShort); }
private RunData CreateNewFromFixture(TestAssembly testAssembly, TestFixture fixture) { RunData item = new RunData() { Fixtures = new List<TestFixture>() { fixture }, Root = Args.Root, Output = new StringBuilder(), Groups = new HashSet<string>(), Exclusive = fixture.Exclusive ?? false, Executable = Args.GetExecutablePath(), RunId = Guid.NewGuid(), AssemblyName = testAssembly.Name }; if (!string.IsNullOrEmpty(fixture.Group)) { item.Groups.Add(fixture.Group); } return item; }
public override MethodEntry CreateMethodEntryFrom(TestFixture fixture, MethodInfo mi) { if (HasValidSignature(mi)) { var attrs = mi.GetCustomAttributes(true); // First try locating framework attributes foreach(Attribute attr in attrs) { if (attr.GetType().FullName.Equals(typeof(TestAttribute).FullName)) { return new MethodEntry(new TestMethod(fixture, mi), MethodType.TestMethod); } if (attr.GetType().FullName.Equals(typeof(SetUpAttribute).FullName)) { return new MethodEntry(new TestMethod(fixture, mi), MethodType.SetUpMethod); } if (attr.GetType().FullName.Equals(typeof(TearDownAttribute).FullName)) { return new MethodEntry(new TestMethod(fixture, mi), MethodType.TearDownMethod); } if (attr.GetType().FullName.Equals(typeof(FixtureTearDownAttribute).FullName)) { return new MethodEntry(new TestMethod(fixture, mi), MethodType.FixtureTearDownMethod); } if (attr.GetType().FullName.Equals(typeof(FixtureSetUpAttribute).FullName)) { return new MethodEntry(new TestMethod(fixture, mi), MethodType.FixtureSetUpMethod); } } // Next we try whether the method is based on naming convention if (mi.Name.ToUpper().StartsWith("TEST")) { return new MethodEntry(new TestMethod(fixture, mi), MethodType.TearDownMethod); } if (mi.Name.ToUpper().Equals("SETUP")) { return new MethodEntry(new TestMethod(fixture, mi), MethodType.SetUpMethod); } if (mi.Name.ToUpper().Equals("TEARDOWN")) { return new MethodEntry(new TestMethod(fixture, mi), MethodType.TearDownMethod); } } else if (mi.ReturnType == typeof(void) && HasTestAttribute(mi)) { // This line needed to address SF1797256 [24mar2008, ml] return new MethodEntry(new ParameterizedTestMethod(fixture, mi), MethodType.TestMethod); } return null; }
public void TestFixtureSetUp() { var config = new HttpConfiguration(); config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional }); config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; config.MessageHandlers.Insert(0, new ServerCompressionHandler(0, new GZipCompressor(), new DeflateCompressor())); this.server = new HttpServer(config); var client = new HttpClient(new ClientCompressionHandler(this.server, 0, new GZipCompressor(), new DeflateCompressor())); client.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip")); client.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("deflate")); this.testFixture = new TestFixture(client); }
public override MethodEntry CreateMethodEntryFrom(TestFixture fixture, MethodInfo mi) { if (HasValidSignature(mi)) { var attrs = mi.GetCustomAttributes(true); foreach (Attribute attr in attrs) { if (attr.GetType().FullName.Equals("NUnit.Framework.TestAttribute")) { return new MethodEntry(new TestMethod(fixture, mi), MethodType.TestMethod); } if (attr.GetType().FullName.Equals("NUnit.Framework.SetUpAttribute")) { return new MethodEntry(new TestMethod(fixture, mi), MethodType.SetUpMethod); } if (attr.GetType().FullName.Equals("NUnit.Framework.TearDownAttribute")) { return new MethodEntry(new TestMethod(fixture, mi), MethodType.TearDownMethod); } if (attr.GetType().FullName.Equals("NUnit.Framework.TestFixtureTearDownAttribute")) { return new MethodEntry(new TestMethod(fixture, mi), MethodType.FixtureTearDownMethod); } if (attr.GetType().FullName.Equals("NUnit.Framework.TestFixtureSetUpAttribute")) { return new MethodEntry(new TestMethod(fixture, mi), MethodType.FixtureSetUpMethod); } } } return null; }
public override MethodEntry CreateMethodEntryFrom(TestFixture fixture, MethodInfo mi) { if (HasValidSignature(mi)) { var attrs = mi.GetCustomAttributes(true); foreach (Attribute attr in attrs) { if (attr.GetType().FullName.Equals("Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute")) { return new MethodEntry(new TestMethod(fixture, mi), MethodType.TestMethod); } if (attr.GetType().FullName.Equals("Microsoft.VisualStudio.TestTools.UnitTesting.TestInitializeAttribute")) { return new MethodEntry(new TestMethod(fixture, mi), MethodType.SetUpMethod); } if (attr.GetType().FullName.Equals("Microsoft.VisualStudio.TestTools.UnitTesting.TestCleanupAttribute")) { return new MethodEntry(new TestMethod(fixture, mi), MethodType.TearDownMethod); } if (attr.GetType().FullName.Equals("Microsoft.VisualStudio.TestTools.UnitTesting.ClassInitializeAttribute")) { return new MethodEntry(new TestMethod(fixture, mi), MethodType.FixtureSetUpMethod); } if (attr.GetType().FullName.Equals("Microsoft.VisualStudio.TestTools.UnitTesting.ClassCleanupAttribute")) { return new MethodEntry(new TestMethod(fixture, mi), MethodType.FixtureTearDownMethod); } } } return null; }
public Min(TestFixture testFixture) : base(testFixture) { }
public NullablePowerQuantity(TestFixture testFixture) : base(testFixture) { }
public ComplexNavigationsWeakQueryInfoCarrierTest(TestFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { }
public abstract MethodEntry CreateMethodEntryFrom(TestFixture fixture, MethodInfo mi);
public static async Task <UpcomingAppointmentsEnvelope> FetchUpcomingAppointments(TestFixture fixture, int barberId) { var dbContext = fixture.GetDbContext(); var upcomingAppointmentsQueryHandler = new UpcomingAppointments.QueryHandler(dbContext); var fetchedUpcomingAppointments = await upcomingAppointmentsQueryHandler.Handle( new UpcomingAppointments.Query(barberId), new CancellationToken()); return(fetchedUpcomingAppointments); }
public Parse(TestFixture testFixture) : base(testFixture) { }
public Meta(TestFixture <Startup> fixture) { _fixture = fixture; _context = fixture.GetService <AppDbContext>(); }
public RepositoryOverrideTests(TestFixture <TestStartup> fixture) { _fixture = fixture; }
/// <summary> /// Initialize the Trias Communicator /// </summary> public TriasCommunicatorTests(TestFixture testFixture) { var serviceProvider = testFixture.ServiceProvider; _communicator = serviceProvider.GetService <ITriasCommunicator>() !; }
public EmailAddressCreateTest(TestFixture fixture) : base(fixture) { this.Login(); this.personListPage = this.Sidenav.NavigateToPeople(); }
public WeightUnitParserTests(TestFixture testFixture) : base(testFixture) { }
public RawAssemblyEndToEndTests(TestFixture fixture) { _fixture = fixture; }
public AzureStorageEndToEndTests(TestFixture fixture) { _storageAccount = fixture.StorageAccount; }
public LazyLoadProxyInfoCarrierTest(TestFixture fixture) : base(fixture) { }
public AjaxControllerTest(TestFixture <Startup> ACustomFixture) => FHttpClient = ACustomFixture.Client;
public when_given_a_null_or_whitespace_name_in_the_query_string(TestFixture fixture) : base(fixture) { }
public RolesControllerTests(TestFixture fixture) : base(fixture) { }
public Max(TestFixture testFixture) : base(testFixture) { }
public CategoryValidatorShould() { fixture = TestFixture.Create(); testModel = fixture.Create <CategoryModel>(); sut = fixture.Create <CategoryValidator>(); }
public DisableQueryAttributeTests(TestFixture <TestStartup> fixture) { _fixture = fixture; }
public async Task OneTimeSetUp() { _fixture = new TestFixture(); await _fixture.InitializeAsync(); }
public DatabaseInitializerTest(TestFixture fixture) { _fixture = fixture; }
public NodeScriptHostTests(TestFixture fixture) { Fixture = fixture; }
public CurrentUserTests(TestFixture <NoAuthStartup> fixture) : base(fixture) { }
public FunctionDispatcherEndToEndTests(TestFixture fixture) { Fixture = fixture; }
public SamplesEndToEndTests_CSharp(TestFixture fixture) { _fixture = fixture; _settingsManager = ScriptSettingsManager.Instance; }
public Confirm_appointment_fails_with(TestFixture testFixture) { _testFixture = testFixture; _fixture = new Fixture(); _fixture.Customize(new CreateAppointmentCustomization()); }
public MaxBySelector(TestFixture testFixture) : base(testFixture) { }
public BasicEntryTests(TestFixture fixture) : base(fixture) { }
public CSharpEndToEndTests(TestFixture fixture) : base(fixture) { }