xunit

How do I mock AddAsync?

不问归期 提交于 2020-03-01 05:55:46
问题 I'm writing unit test. For testing the method below, public async Task<Guid> CreateWebJobStatus(string blobId, Guid loggedInUserId, string loggedInUserEmail) { Guid webJobStatusId = Guid.NewGuid(); WebJobStatus newWebJobStatus = new WebJobStatus { WorkJobStatusId = webJobStatusId, TransactionId = Guid.NewGuid(), Status = (int)WebJobStatusEnum.PENDING, BlobId = blobId, UserId = loggedInUserId, UserEmail = loggedInUserEmail, }; await _dbContext.WebJobStatus.AddAsync(newWebJobStatus); await

How do I mock AddAsync?

巧了我就是萌 提交于 2020-03-01 05:55:46
问题 I'm writing unit test. For testing the method below, public async Task<Guid> CreateWebJobStatus(string blobId, Guid loggedInUserId, string loggedInUserEmail) { Guid webJobStatusId = Guid.NewGuid(); WebJobStatus newWebJobStatus = new WebJobStatus { WorkJobStatusId = webJobStatusId, TransactionId = Guid.NewGuid(), Status = (int)WebJobStatusEnum.PENDING, BlobId = blobId, UserId = loggedInUserId, UserEmail = loggedInUserEmail, }; await _dbContext.WebJobStatus.AddAsync(newWebJobStatus); await

F# Reactive wait for Observable to complete

 ̄綄美尐妖づ 提交于 2020-03-01 05:41:26
问题 I found a variety of SO questions on this but couldn't figure out an F# solution. I need to block wait for an event to fire at me to check the data it returns. I am using Rx to receive event 3 times: let disposable = Observable.take 3 ackNack |> Observable.subscribe ( fun (sender, data) -> Console.WriteLine("{0}", data.AckNack) Assert.True(data.TotalAckCount > 0u) ) I would like to either turn results into a list, so they can be checked later on by the test framework (xUnit), or wait for all

XUnit Test different results under netcoreapp1.1 and net462

被刻印的时光 ゝ 提交于 2020-02-08 06:09:35
问题 I created a XUnit test projects in VS 2017, its target framework is netcoreapp1.1, and below code works correctly. using Xunit; using Xunit.Abstractions; using Xunit.Ioc.Autofac; namespace XUnitTestProject2 { [UseAutofacTestFramework] public class MyAwesomeTests { public MyAwesomeTests() { } public MyAwesomeTests(ITestOutputHelper outputHelper) { _outputHelper = outputHelper; } [Fact] public void AssertThatWeDoStuff() { _outputHelper.WriteLine("Hello"); } private readonly ITestOutputHelper

how do I mock sqlconnection or should I refactor the code?

痞子三分冷 提交于 2020-01-30 02:39:14
问题 I have the code below, I have read Moq and SqlConnection? and How can I stub IDBconnection, but I still have no idea how to mock the following sqlconnection. public class SqlBulkWriter : ISqlBulkWriter { private readonly string _dbConnectionString;; public SqlBulkWriter(string dbConnectionString) { this._dbConnectionString = dbConnectionString; } public void EmptyTable(string schema, string tableName) { using (var connection = new SqlConnection(this._dbConnectionString)) { try { connection

xUnit tests under F# : It looks like you're trying to execute an xUnit.net unit test ('System.ArgumentException' occurred in xunit.runner.utility.dll)

▼魔方 西西 提交于 2020-01-25 11:53:29
问题 0. My setup is as follows Visual Studio 2012 Ultimate, update 3, v.11.0.60610.01 Visual F# 2012 04940-004-0038003-02527 TestDriven.Net 3.5 Beta 3 Personal 1. What I have in packages.config: <?xml version="1.0" encoding="utf-8"?> <packages> <package id="FsUnit.xUnit" version="1.2.1.2" targetFramework="net45" /> <package id="xunit" version="1.9.1" targetFramework="net45" /> </packages> 2. What I ran: xunit.installer.exe 3. This is what the packages folder looks like \packages\FsUnit.xUnit.1.2.1

Why my few test case get failed after “Running all” controller and pass individually?

孤者浪人 提交于 2020-01-25 07:52:05
问题 When I execute my all controllers mock test cases then some of the test cases get failed but they got pass individually. I used Dispose() where I was using the same variable thought the unit test but still, it does not fix. In my project, I made a common setup Example: AbcMock public class AbcMock { public static Mock<IAbcMock> abcMock; public static void Setup() { abcMock = new Mock<IAbcMock>(); abcMock.Setup(x => x.GetAll(It.IsAny<Guid>())).Returns(1); } } Then i have made common setup to

MSBuild - trying to run xUnit (.net) tests

断了今生、忘了曾经 提交于 2020-01-14 09:08:09
问题 I'm trying to set up a C# project that'll run xUnit tests when I build, so I can use them in continuous integration. I have a regular project, a class library test project using xUnit, and my test runner project. From everything I've read, it appears that I should be able to get this working by doing this in the test runner project: <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Test" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> [auto

How can I run xUnit Unit Tests with VS2015 Preview?

纵饮孤独 提交于 2020-01-13 07:41:52
问题 I added the "xUnit.net runner for Visual Studio" v0.99.8 via Extensions Manager, but when I open the Test Explorer window, it does not seem to pick up any of my unit tests. Also, the Resharper 9 EAP does which is the only version of Resharper that supports VS2015 does seem yet to have the plugin for xUnit Test Runner. How then, can I run xUnit Unit Tests in VS2015 Preview? 回答1: You can find the answer here: http://blogs.msdn.com/b/webdev/archive/2014/11/12/announcing-asp-net-features-in