xunit

xUnit theory test using generics

纵然是瞬间 提交于 2019-12-12 07:45:16
问题 In xUnit I can have a Theory test that uses generics in this form: [Theory] [MemberData(SomeScenario)] public void TestMethod<T>(T myType) { Assert.Equal(typeof(double), typeof(T)); } public static IEnumerable<object[]> SomeScenario() { yield return new object[] { 1.23D }; } Which will give me the generic T parameter as double . Is it possible to use MemberData to specify the generic type parameter for a test with a signature like: [Theory] [MemberData(SomeTypeScenario)] public void

IdentityServer3 xBehave test

99封情书 提交于 2019-12-12 03:54:03
问题 I wanted to write acceptance tests for my WebApi and IdentityServer. To keep things as simple as possible I copied the whole sample project from here but added another project, that essentially makes the same as the console client would but as a acceptance test. The only scenario I got right now is this: namespace SpecTesting { using System; using System.Net; using System.Net.Http; using System.Threading; using FluentAssertions; using IdentityModel.Client; using Xbehave; public class

Coloring occasional lines in full XML Structure and show in HTML

ⅰ亾dé卋堺 提交于 2019-12-12 03:47:22
问题 My First question is marked as duplicated, but it isn't a duplicate show XML in HTML with inline stylesheet I hope this question is not immediatley marked as duplicate, only because one of the moderators has read the first two sentences and've ignored the rest. The Problem is not to show an XML Structure in HTML, rather to show a full dynamically XML structure, with all tags and occasional colored lines. The structure and interior fields are full dynamically and every field can be correct or

Getting Specflow Tag in WebDriver Method

狂风中的少年 提交于 2019-12-12 03:33:42
问题 I am running an automated test suite using c#, selenium, and specflow. If possible, I would like to be able to see what tag(s) are assigned to the current scenarios so I can instantiate a certain browser type per scenario. Is this even possible using XUnit?? Login Feature File: Feature: Login In order to login to DRIVE As a user We have to enter login details Background: Given I am on the login page @headless Scenario: Logging in as a valid user And I enter a valid user and password When I

TestStartup contained in a TestProject that inherits from API.Startup (contained in separate project) causes 404 error

怎甘沉沦 提交于 2019-12-11 17:41:55
问题 I am trying to use a StartupTest.cs with XUnit and TestServer. I have followed these instructions using Visual Studio 2017 15.9.3: 1) Create a new solution. 2) Add an ASP.Net Core web application (web API) to the project. Call it API. No Https or Docker. 3) Add a xUnit Test project (.NET Core) to the solution. Call it: XUnitTestProject1 4) Add a reference to the Web API project from the XUnit project. 5) Install the following Nuget packages in the XUnit project: Microsoft.AspNetCore.TestHost,

Error encountered when running dotcover console runner using xunit as the target executable

我与影子孤独终老i 提交于 2019-12-11 14:49:57
问题 I am using the DotCover console runner to check out the code coverage. Here is the command line I used - C:.\dotcover.exe cover /TargetExecutable="C:\packages\xunit.1.9.2\ lib\net20\xunit.runner.msbuild.dll" /TargetArguments="C:\bin\myConfigFolder\My.Tests.dll" /Output="c:\temp\CoverageReport.html" /ReportType="HTML" But I am getting the message below - JetBrains dotCover Console Runner v2.7.4.24. Copyright (c) 2009-2015 JetBrains s.r.o. All rights reserved. [JetBrains dotCover] Coverage

How To Run Xunit in VisualStudioOnline Build

浪子不回头ぞ 提交于 2019-12-11 12:02:59
问题 I've VS2015 RC project in my visual studio online account. In this project the tests are written with xunit. In the project I've added the following nuget packages <package id="xunit" version="2.1.0-beta3-build3029" targetFramework="net46" userInstalled="true" /> <package id="xunit.abstractions" version="2.0.0" targetFramework="net46" userInstalled="true" /> <package id="xunit.assert" version="2.1.0-beta3-build3029" targetFramework="net46" userInstalled="true" /> <package id="xunit.core"

Integrating Node.js with QUnit to Jenkins

荒凉一梦 提交于 2019-12-11 11:06:07
问题 This is my first sof post so forgive my format and organization of thought. I've made a great effort to solve my problem before posting this. Part of my issue could be lack of knowledge with packages in Ubuntu or Node.js so please guide me. I'm trying to create a XUnit xml file for Jenkins from QUnit tests for a Node.js application. I don't have the ability to run a browser or even a headless browser, also don't understand why I'd need one since the Node.js code doesn't deal with the browser.

xUnit theory guids as parametr

99封情书 提交于 2019-12-11 08:43:33
问题 I have extension method which tests if string is GUID. public static bool IsGuid(this string str) { if(str == null) throw new ArgumentNullException(str, "Argument can not be NULL"); Guid guidFromString; return Guid.TryParse(str, out guidFromString); } I want test it via xUnit and Theory. For string it's working: [Theory, InlineData(""), InlineData(" ")] public void IsGuid_EmptyOrWhiteSpace_ShouldReturnFalse(string str) { // Arrange bool result; // Act result = str.IsGuid(); // Assert Assert

ASP.Net Web API 2 Controller Unit Test Get Request Item Count

不羁岁月 提交于 2019-12-11 04:27:20
问题 I am trying to develop an Xunit test to establish if my Controller under test is returning the correct number of objects. The Controller's getAreas function is as follows: [HttpGet()] public IActionResult GetAreas() { _logger.LogTrace("AreasController.GetAreas called."); try { // Create an IEnumerable of Area objects by calling the repository. var areasFromRepo = _areaRepository.GetAreas(); var areas = _mapper.Map<IEnumerable<AreaDto>>(areasFromRepo); // Return a code 200 'OK' along with an