mspec

Is there a workaround for setting [HostType(“Moles”)] when dealing with anonymous methods in MSpec?

吃可爱长大的小学妹 提交于 2020-01-15 06:26:25
问题 I'm using Pex and Moles for my low-level unit testing, but I'm also exploring MSpec for business-logic validation, and would like to keep using Moles for consistency. The problem, I think, is that MSPec uses anonymous methods, so there's no way to apply the HostType("Moles") attribute. For example: Because of = () => employeeList = EmployeeManager.GetUsersByRoles(rolesToLoad); It should_return_a_list_of_employees = () => employeeList.ShouldNotBeNull(); I'm mocking the Roles provider called

FakeItEasy Proxy methods calls to real implementation

末鹿安然 提交于 2020-01-01 09:36:05
问题 I'm trying to proxy calls to a fake object to the actual implementation. The reason for this is that I want to be able to use the WasToldTo and WhenToldTo of Machine.Specifications which only works on fakes of an interface type. Therefore I'm doing the following to proxy all calls to my real object. public static TFake Proxy<TFake, TInstance>(TFake fake, TInstance instance) where TInstance : TFake { fake.Configure().AnyCall().Invokes(x => x.Method.Invoke(instance, x.Arguments.ToArray()));

How do I do unit & integration testing in a BDD style in ASP.NET MVC?

[亡魂溺海] 提交于 2020-01-01 02:28:10
问题 I am learning Behavior Driven Development with ASP.NET MVC and, based on a post from Steve Sanderson, understand that BDD can mean, at least, the following test types: individual units of code & UI interactions. Something similar is mentioned in this post. Do I need two different test frameworks if I want both unit and integration testing? Unit testing repositories, controllers, & services using a context/specification framework, like MSpec. The results of testing with this will be useful to

How can I prevent ReSharper from inserting a blank line between my MSpec fields?

余生颓废 提交于 2019-12-24 17:09:25
问题 When I write an MSpec context like this: [Subject(typeof(TheType), "Concern")] internal class when_this_test_is_run { Establish context = () => { // some code... }; Because of = () => Do.Something(); It should_do_this; It should_do_that; } When I let ReSharper reformat the code, it always inserts a blank line beneath any of the delegates that is an anonymous method, i.e. has a { block } as its body. It doesn't insert blank lines after delegates that are simple expressions. So in the example

Unable to run MSpec test due to the fact that TeamCity is building test assembly wrong

ぃ、小莉子 提交于 2019-12-24 07:26:59
问题 I am trying to run a MSpec test following the build of my solution. So, I've got my MSBuild script set up as follows: <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Target Name="Build"> <MSBuild Projects="../MyApplication.Web.sln" /> <Message Text="Building solution" Importance="high" /> </Target> <Target Name="TeamCity" DependsOnTargets="Build"> <Message Text="Before executing MSpec

C# in my unit test i want to see if it is null or an empty string

送分小仙女□ 提交于 2019-12-24 03:07:05
问题 I'm using Machine spec / Shouldly and testing a mapping profile (mundane work). The mapping expectations are sometimes inconsistent. Sometimes I am seeing an "" explicit empty string get returned and sometimes it's a null value. Since we're mapping to a spreadsheet it doesn't matter on that front but it gets a little annoying when asserting. Is there a way in Machine spec to do something like assertionValue.ShouldEqual(null || "") ? 回答1: Assert on the outcome of string.IsNullOrEmpty() 来源:

Why does Visual Studio 2015 console runner not recognize MSpecs?

孤者浪人 提交于 2019-12-23 15:14:46
问题 I've written some MSpecs, but Visual Studio (2015) test runner does not recognize them. I've added the Machine.Specifications.Runner.Console and all required Machine.Specification -packages using the NuGet-PM. But when I choose Test->Run Test , the mspec-containing file is not even listed. Beyond is an example of the mspecs I wrote so far, which is located in an own project/solution that contains some other (regular unit) test, which all run fine btw. [Subject(typeOf(ControllerForm)] public

Help configuring MSpec

半腔热情 提交于 2019-12-23 03:44:12
问题 rig: win7 64bit, vs2010, mvc v2, TestDriven.Net 3.0, Reshaper 5.0, MSpec 0.3 i recently started a new project and want to use mspec. (1) copied Machine.Specifications.ReSharperRunner.5.0.dll and Machine.Specifications.dll to JetBrains\ReSharper\5.0\Bin\Plugins\Machine.Specifications (2) copied Machine.Specifications.TDNetRunner.dll to TestDriven.NET 3\Machine.Specifications when i try to run the test i get this error: System.IO.FileNotFoundException: Could not load file or assembly 'Machine

Should I use specflow at unit test level? [duplicate]

落花浮王杯 提交于 2019-12-20 12:24:12
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: SpecFlow/BDD for Unit Tests? Over the last few years I have worked in TDD using NUnit/Moq and over the last few months I have been getting to grips with BDD using mSpec. So far so good but we now want to move more into acceptance criteria based tests where the business analysts are involved and we get an outside in development process. So now we have predefined Gherkin syntax files and with specflow it feels the

How is static object state shared/set between MSpec contexts?

血红的双手。 提交于 2019-12-12 13:11:44
问题 While writing some MSpec BDD tests I came across a scenario where a test that I was expecting to fail was passing, but only when I ran all of my tests. When I ran the test in isolation it failed as expected. After some investigation I found that some state that was set in a previous test was not being reset before the second test was running and this was causing the second test to pass when I expected it to fail. The following contrived code reproduces the scenario: public class ContextBase {