mspec

Using MSpec runner in Visual Studio 2010 and .NET 4

Deadly 提交于 2019-12-07 04:58:53
问题 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 MSpec runner (mspec.exe) with a .NET 4.0 solution I get the following error: Could not load file or assembly 'file:///C:\Users\[SOMEUSER]\[SOME_FOLDERS]\bin\Debug\[PROJECT].Specs.dll' or one of its dependencies. This assembly is built by a runtime

Why do I get a NullReferenceException when testing this async method with MSpec/Moq?

瘦欲@ 提交于 2019-12-06 00:16:22
I want test if the correct type is returned from an async method. This method uses another async method in a dependency class. The dependency class implements this interface: Task<string> DownloadStringAsync(string url); The method I want to test is this: public async Task<T> GetData<T>(string url) where T : class , new() { var jsonData = await _webClientWrapper.DownloadStringAsync(url); if (string.IsNullOrEmpty(jsonData)) return new T(); try { return await JsonConvert.DeserializeObjectAsync<T>(jsonData); } catch (JsonException inner) { throw new JsonConvertException("Error converting Json

DRY-ing very similar specs for ASP.NET MVC controller action with MSpec (BDD guidelines)

依然范特西╮ 提交于 2019-12-05 10:56:04
I have two very similar specs for two very similar controller actions: VoteUp(int id) and VoteDown(int id). These methods allow a user to vote a post up or down; kinda like the vote up/down functionality for StackOverflow questions. The specs are: VoteDown: [Subject(typeof(SomeController))] public class When_user_clicks_the_vote_down_button_on_a_post : SomeControllerContext { Establish context = () => { post = PostFakes.VanillaPost(); post.Votes = 10; session.Setup(s => s.Single(Moq.It.IsAny<Expression<Func<Post, bool>>>())).Returns(post); session.Setup(s => s.CommitChanges()); }; Because of =

Using MSpec runner in Visual Studio 2010 and .NET 4

送分小仙女□ 提交于 2019-12-05 07:25:50
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 MSpec runner (mspec.exe) with a .NET 4.0 solution I get the following error: Could not load file or assembly 'file:///C:\Users\[SOMEUSER]\[SOME_FOLDERS]\bin\Debug\[PROJECT].Specs.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. I can still run my specs with the Resharper

How do I run MSpec test assemblies in parallel?

寵の児 提交于 2019-12-04 11:22:29
We have the following setup: Team City v8.1.2 .NET 2013 Solution with several different C# projects (ASP.NET MVC, libraries, testing projects, etc.) 95% of our tests are MSpec, but we also have some NUnit tests. We have 14 test projects and growing... Currently the testing phase is taking, roughly, 9 minutes for MSpec tests and 1 minute for NUnit. We would like to start parallelizing this, as we expect the number of tests to grow quickly. What would be the best solution, provided that: MSpec doesn't seem to have any parallel runner. The tests should be parallelized per assembly, which tests

What are some strategies for testing large state machines?

我们两清 提交于 2019-12-04 07:53:09
问题 I inherited a large and fairly complex state machine. It has 31 possible states, all are really needed (big business process). It has the following inputs: Enum: Current State (so 0 -> 30) Enum: source (currently only 2 entries) Boolean: Request Boolean: Type Enum: Status (3 states) Enum: Handling (3 states) Boolean: Completed Breaking it into separate state machines doesn't seem feasible, as each state is distinct. I wrote tests for the most common inputs, with one test per input, all inputs

FakeItEasy Proxy methods calls to real implementation

北城以北 提交于 2019-12-04 05:24:40
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())); return fake; } I would use that like this. var fake = Proxy<ISomeInterface, SomeImplementation>(A.Fake

Spec fails when run by mspec.exe, but passes when run by TD.NET

走远了吗. 提交于 2019-12-03 18:15:17
问题 I wrote about this topic in another question. However, I've since refactored my code to get rid of configuration access, thus allowing the specs to pass. Or so I thought. They run fine from within Visual Studio using TestDriven.Net. However, when I run them during rake using the mspec.exe tool, they still fail with a serialization exception. So I've created a completely self-contained example that does basically nothing except setup fake security credentials on the thread. This test passes

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

寵の児 提交于 2019-12-03 05:58:52
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 the development team. Testing complete behaviors (integration) using a given/when/then framework, like

What are some strategies for testing large state machines?

╄→尐↘猪︶ㄣ 提交于 2019-12-02 19:17:26
I inherited a large and fairly complex state machine. It has 31 possible states, all are really needed (big business process). It has the following inputs: Enum: Current State (so 0 -> 30) Enum: source (currently only 2 entries) Boolean: Request Boolean: Type Enum: Status (3 states) Enum: Handling (3 states) Boolean: Completed Breaking it into separate state machines doesn't seem feasible, as each state is distinct. I wrote tests for the most common inputs, with one test per input, all inputs constant, except for the State. [Subject("Application Process States")] public class When_state_is