Questions tagged [mspec]

Machine.Specifications is a context/specification framework for C#. Not to be confused with the mspec Ruby framework (tag [mspec-ruby]) used in RubySpecs.

Machine.Specifications is a context/specification framework for C# geared towards removing language noise and simplifying tests.

215 questions
7
votes
1 answer

MSpec, what should I put in my [Subject()] attributes?

I've been using MSpec for a little while and I really like it. I've found that to get ReSharper to recognize my specifications, I need to use a SubjectAttribute. I'm wondering though, what's the best thing to put in the [Subject()] attributes? If…
Tim Long
  • 13,508
  • 19
  • 79
  • 147
7
votes
2 answers

Unexpected Validate behavior with Moq

Moq has been driving me a bit crazy on my latest project. I recently upgraded to version 4.0.10827, and I'm noticing what seems to me to be a new behavior. Basically, when I call my mocked function (MakeCall, in this example) in the code I am…
7
votes
2 answers

How do I fake a user log in for unit testing purposes using fakeiteasy within asp.net mvc 2

I have just started learning and usingASP.NET MVC 2 and also getting more involved into unit testing my code. My question is broadly how to simulate a user log in by passing in credentials within my test. I am using MSpec and trying to get my head…
DavidS
  • 2,179
  • 4
  • 26
  • 44
7
votes
1 answer

Does MSpec support "row tests" or data-driven tests, like NUnit TestCase?

We are using Machine.Specification as our test framework on my current project. This works well for most of what we are testing. However, we have a number of view models where we have 'formatted' properties that take some raw data, apply some logic,…
Hamman359
  • 1,052
  • 2
  • 14
  • 27
7
votes
1 answer

FakeItEasy Proxy methods calls to real implementation

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…
Marco
  • 4,817
  • 5
  • 34
  • 75
7
votes
5 answers

What BDD frameworks are popular in .net?

I've recently been getting into BDD and think it holds great promise as a way to get a stakeholder's voice back in the apps we, as developers, create for them. What's your favorite BDD framework and why?
Lee Warner
  • 2,543
  • 4
  • 30
  • 45
7
votes
1 answer

Why is MSpec's ShouldBeOfType assertion extension method missing?

I'm trying to use Mspec's ShouldBeOfType() assertion extension method, but intellisense says that it can't find it. I'm using MSpec v0.7.0. I tried reinstalling using Nuget but didn't work. [Subject("Prop Manager")] public class…
AllSpark
  • 425
  • 1
  • 4
  • 17
7
votes
2 answers

Why doesn't my Equals method get called?

I'm working through Kent Beck's TDD by Example as an academic exercise, but using MSpec to write the tests. When following worked examples, I like to introduce a twist so that I can't simply copy the text out rote, I find that way I tend to run into…
Tim Long
  • 13,508
  • 19
  • 79
  • 147
6
votes
3 answers

How do I suppress or fix Visual Studio warnings that MSpec Behaves_like fields are unused?

I am writing idiomatic MSpec specs using Behaviors and Behaves_like fields [Subject(typeof(IUnitMaskConverter))] public class When_converting_unit_masks_by_lookup { Behaves_like a_unit_mask_converter; protected…
Anthony Mastrean
  • 21,850
  • 21
  • 110
  • 188
6
votes
3 answers

Changing resharper settings to suit mspec coding

When I create a new test like the following: It should_get_something = () => foo(); When I hit the semi-colon resharper sticks private on the front of the delegate: Private It should_get_something = () => foo(); I then have to remove it. Can I tell…
78lro
  • 1,790
  • 7
  • 37
  • 63
6
votes
2 answers

Using MSpec runner in Visual Studio 2010 and .NET 4

I'm a big fan of MSpec so naturally I wanted to use is right away with VS2010 as well. I have the MSpec runner defined as an external tool in Visual Studio to be able to have it always visible as a toolbar item. Anyway, whenever I try to use the…
Sergi Papaseit
  • 15,999
  • 16
  • 67
  • 101
6
votes
4 answers

How do I build this Expression with Moq without getting a method group error?

I need to run an expression on a given collection to determine if the expression in the code is written correctly. For the sake of the example, I am going to leave out some unnecessary context, but if anyone needs it, just comment and I'll edit the…
David Sulpy
  • 2,277
  • 2
  • 19
  • 22
6
votes
1 answer

Why do I get a NotSupportedException when running MSpec on TeamCity?

When running an MSpec build step in TeamCity I am getting the following error in the team city logs: [Step 7/7] Starting: C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.NUnitLauncher.exe #TeamCityImplicit [17:07:13][Step 7/7]…
78lro
  • 1,790
  • 7
  • 37
  • 63
5
votes
2 answers

Why won't MSpec integrate with ReSharper 6?

I'm having trouble with getting MSpec to work with ReSharper 6. I've just installed MSpec from the NuGet package: Next, I've quit from Visual Studio, opened an elevated command prompt and run the install script from the packages\tools folder: And…
Tim Long
  • 13,508
  • 19
  • 79
  • 147
5
votes
3 answers

How to test HTTP status code set by an ASP.NET MVC action with MSpec

I have the following controller: public sealed class SomeController : Controller { public ActionResult PageNotFound() { Response.StatusCode = 404; return View("404"); } } I have created an MSpec…
Arnold Zokas
  • 8,306
  • 6
  • 50
  • 76
1
2
3
14 15