nunit

Testing property set by async method

醉酒当歌 提交于 2019-12-12 05:24:46
问题 I try to test a class with NUnit that contains async methods. I don't know how to do it in a correct way. I have a class with that looks like this: public class EditorViewModel:INotifyPropertyChanged { public void SetIdentifier(string identifier) { CalcContentAsync(); } private async void CalcContentAsync() { await SetContentAsync(); DoSomething(); } private async Task SetContentAsync() { Content = await Task.Run<object>(() => CalculateContent()); RaisePropertyChanged("Content"); } public

How to mock a melthod with out paramter in Moq AND fill the out

徘徊边缘 提交于 2019-12-12 04:57:22
问题 I have see several questions here in Stackoverflow about out parameters in MOQ, my question is how fill this parameter: Lets to code: [HttpPost] public HttpResponseMessage Send(SmsMoRequest sms) { if (sms == null) return Request.CreateResponse(HttpStatusCode.BadRequest); SmsMoResponse response; _messageService.Process(sms, out response); return Request.CreateResponse(HttpStatusCode.Created, response.ToString()); } I want to test this post: [Test] public void Should_Status_Be_Create_With_Valid

what test data approach/framework is recommended for .net unit testing

坚强是说给别人听的谎言 提交于 2019-12-12 04:34:45
问题 what test data approach/framework is recommended for .net unit testing? I'm in VS2010, C#, doing business logic layer testing. By approaches I mean like: creating database snapshots, programmatically creating each time, etc etc. Like what approach to use to ensure at the start of each test the database is in a known state. 回答1: Some would say that if you're using the database, then you're doing functional testing, not unit testing. 回答2: This is not directly related to database testing. But in

FsUnit: Unable to test portable library due to it and test project having different F#.Core versions

我们两清 提交于 2019-12-12 04:27:17
问题 I have a Portable Library, for which the FSharp.Core version is 3.7.4.0 . Installing (in the Unit Test project) FsUnit installs, as a dependency, FSharp.Core version 3.1.2.5 . Due to this, using the portable library's functions in my Unit Test project, for example: module StammaTests.PieceTests open Stamma open NUnit.Framework open FsUnitTyped [<Test>] let ``Testing a Basic function`` () = Piece.toChar Black King |> shouldEqual 'k' yields error: Result Message: System.IO.FileLoadException :

Webdriver C# how to set driver timeouts with multiple browsers

橙三吉。 提交于 2019-12-12 04:18:56
问题 Hoping to find my answer here I have spent the better half of a week trying to figure this out myself and I cannot fix my issue. A little background, I am new to C# and NUnit tests with webdriver, I am attempting to create a regression suit for the company I work for. We have a few products that are heavily integrated with ebay and so for part of the test I need to click on a button which takes me to the ebay login page and then I need to login. Seems simple enough (or so I thought). The

How to debug with vs.net 2008 and nunit?

▼魔方 西西 提交于 2019-12-12 03:21:49
问题 I am running vs.net 2008 with nunit runner. If I set a breakpoint in the unit test code, it just runs the unit test in the runner. I'm guessing I have to integrate nunit with vs.net somehow? My unit tests are just a class library project, I cannot run the tests in vs.net 2008, I can only do it via the runner currently. 回答1: If you want to debug in your current setup (running nunit runner that has your assemblies loaded), do the following: Run nunit.exe Open (or create) your nunit project

Not able to execute Second Test Method in Nunit selinium

余生长醉 提交于 2019-12-12 03:15:20
问题 I am using Selinium webdriver, Nunit framework and working with IE browser. I have the below code. Tt is not executing second method(add hazard). I am pasting code and stack trace. Could some one let me know where it went wrong. Thanks in advance. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using OpenQA.Selenium; using OpenQA.Selenium.IE; using NUnit.Framework; using OpenQA.Selenium.Interactions; using OpenQA.Selenium

How do you stop the DiaSession warning from TFS CI build when using NUnit?

冷暖自知 提交于 2019-12-12 02:56:20
问题 How do you stop the DiaSession warning from TFS CI build when using NUnit? 0 error(s), 1 warning(s) Unable to create DiaSession for .... No source location data will be available for this assembly. 回答1: You need to use add the /p:NoWarn=warningNumber in MSBuild Arguments in the build definition. Or use the /p:WarningLevel=0 argument to suppress all warnings. 来源: https://stackoverflow.com/questions/33548560/how-do-you-stop-the-diasession-warning-from-tfs-ci-build-when-using-nunit

Runnin NUnit from code - how to output results to console?

大城市里の小女人 提交于 2019-12-12 02:48:29
问题 I am running NUnit tests using RemoteTestRunner . In the end, I get a TestResult object containing the results. The unit test project compiles as a console app. The problem is, after running the tests, the output gets somehow redirected, and I can't print the results to the console. Here's the code. It doesn't output anything , not even "Open, sesame!" (although it does run to the end - confirmed in the debugger). Any suggestions? Also, is there a built-in way to list the failed results given

How To use NUnit DynamicMock to mock non-Interface and non-MarshalByRef

依然范特西╮ 提交于 2019-12-12 02:48:13
问题 i am writing a Class wich will be initialised with a Socket. I want to write a Test using an NUnit DynamicMock. How can i create a Mock of the Socket without much effort? DynamicMock DynamicSocketMock = new DynamicMock(typeof (Socket)); /*No ERROR - BUT I THINK HERE IS THE PROBLEM*/ Socket SocketMock = (Socket) DynamicSocketMock.MockInstance; /*RUNTIME ERROR*/ ToBeTested Actual = new ToBeTested(SocketMock); /*NEVER REACHED*/ Edit #1 I looked into moq nad it looks quite nice however i still