nunit

Using both MSTest and NUnit?

狂风中的少年 提交于 2019-12-21 07:06:53
问题 Reading about MSTest and NUnit I couldn't really decide what to use in my project. We use TFS 2008 and VS2010. I like MSTest because of its integration into VS2010, Continuous Integration and Code Coverage reports. I like NUnit because it allows to formulate complex assert statements in a nice, readable fashion. Stumbling upon http://alsagile.com/archive/2010/03/09/stop-the-war-between-nunit-and-mstest-make-them.aspx I ask the community: is it possible to use both? I also think about sticking

how to assert if a method has been called using nunit

て烟熏妆下的殇ゞ 提交于 2019-12-21 06:57:46
问题 is it possible to assert whether a method has been called? I'm testing the following method and I want to assert that the _tokenManager.GetToken() has been called. I just want to know if the method has been called as the method does not return a value. I am using Moq. Thanks, Code snippet public void Subscribe(string code, string emailAddress, string columnKey) { // Request authentication token var token = _tokenManager.GetToken(code, false); if (!_tokenValidator.Validate(token)) { // Token

Trying to use Moles with NUnit. Getting “Moles requires tests to be an instrumented process”

和自甴很熟 提交于 2019-12-21 05:16:09
问题 I am trying to use moles with NUnit and am getting the following error "Moles requires tests to be an instrumented process". I am also using Visual NUnit within Visual Studio 2008 to get this working. Any help is welcome. 回答1: This is what I did in order to make Moles work with NUnit: Grab the archive at C:\Program Files (x86)\Microsoft Moles\Documentation\moles.samples.zip and extract the Moles solution folder. Build the NUnit project in Visual Studio (2008) for Release. Copy the output

Pass lambda to parameterized NUnit test

大憨熊 提交于 2019-12-21 04:21:35
问题 I have a class with a bunch of overloaded operators: public static double[,] operator +(Matrix matrix, double[,] array) public static double[,] operator -(Matrix matrix, double[,] array) public static double[,] operator *(Matrix matrix, double[,] array) For all of them I'd like to test operands for null. I have an NUnit test for that: public void MatrixOperatorOperandIsNullThrows(Func<Matrix, double[,], double[,]> op) { Matrix m = null; var right = new double[,] {{1, 1}, {1, 1}}; Assert

Pass lambda to parameterized NUnit test

有些话、适合烂在心里 提交于 2019-12-21 04:21:29
问题 I have a class with a bunch of overloaded operators: public static double[,] operator +(Matrix matrix, double[,] array) public static double[,] operator -(Matrix matrix, double[,] array) public static double[,] operator *(Matrix matrix, double[,] array) For all of them I'd like to test operands for null. I have an NUnit test for that: public void MatrixOperatorOperandIsNullThrows(Func<Matrix, double[,], double[,]> op) { Matrix m = null; var right = new double[,] {{1, 1}, {1, 1}}; Assert

Limitations of using C++/CLI with NUnit

跟風遠走 提交于 2019-12-21 04:14:53
问题 This answer to a question about C++ unit test frameworks suggests a possibility that had not occurred to me before: using C++/CLI and NUnit to create unit tests for native C++ code. We use NUnit for our C# tests, so the possibility of using it for C++ as well seems enticing. I've never used managed C++, so my concern is are there any practical limitations to this approach? Are many of you doing this? If so, what was your experience like? 回答1: We do this all of the time. We have many

How do I test multiple browsers with selenium and a single NUnit suite and keep it DRY?

岁酱吖の 提交于 2019-12-21 04:09:18
问题 I'm looking for a way to reuse one NUnit test suite without duplicating the entire suite for each browser. It seems like I would need a new fixture for each browser. Can I send some sort of environment variable or configuration setting from the NUnit gui to switch the browser? see below: [TestFixture] public class User { private ISelenium selenium; private StringBuilder verificationErrors; [SetUp] public void SetupTest() { // TheBrowser = How do I populate this variable from the NUnit gui?

C#, NUnit Assert in a Loop

老子叫甜甜 提交于 2019-12-21 03:49:08
问题 I have a school assignment where I need to create a data-driven style of NUnit testing. Using the below code, I am able to get the data from the database, but everytime an 'Assert' call fails, the test is stopped. Is there any way in which I can actually show the results of the loop as six different tests (considering I have six rows in my database)? namespace TestClasses { [TestFixture] public class TestingClass : ConnectionClass { private ProductManagement pm; [TestFixtureSetUp] public void

Is it bad form to count on the order of your NUnit unit tests

…衆ロ難τιáo~ 提交于 2019-12-21 03:42:45
问题 I have been creating Unit tests like crazy and find that I'm often having to set up something in one test that I just tore down in a previous test. Is it ever reasonable to create something (e.g. a database record) in one test (e.g. an Insertion test) and then use it for a later test (e.g. a Deletion test)? Or should each and every test always stand completely on its own? Can you even determine the order of tests in NUnit or are they always done alphabetically? Note: I am specifically asking

Why do async unit tests fail when the async/await keywords aren't used?

本秂侑毒 提交于 2019-12-21 03:34:15
问题 According to this discussion, there should be no difference between the following two methods: public async Task Foo() { await DoSomethingAsync(); } public Task Foo() { return DoSomethingAsync(); } Actually, it would seem that for very simple methods, the invocation without the async/await keywords would be preferred, as they remove some overhead. However, this apparently doesn't always work in unit tests. MSTest [TestClass] public class AsyncTest { [TestMethod] public async Task Test1() {