Skip to content

Commit

Permalink
Merge pull request #70 from midripps/vb
Browse files Browse the repository at this point in the history
Fix for #69 NSpec and VB.NET
  • Loading branch information
amirrajan committed Jul 21, 2014
2 parents 67a88dd + aa77a50 commit 9bb420a
Show file tree
Hide file tree
Showing 15 changed files with 580 additions and 1 deletion.
12 changes: 12 additions & 0 deletions NSpec.sln
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{39769B
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleSpecsFocus", "SampleSpecsFocus\SampleSpecsFocus.csproj", "{17D2A12B-FCB1-4528-BA18-80FCE760249B}"
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "NSpecSpecsVB", "NSpecSpecsVB\NSpecSpecsVB.vbproj", "{FBCF1115-4F77-4706-AE32-B4251561C492}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -102,6 +104,16 @@ Global
{17D2A12B-FCB1-4528-BA18-80FCE760249B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{17D2A12B-FCB1-4528-BA18-80FCE760249B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{17D2A12B-FCB1-4528-BA18-80FCE760249B}.Release|x86.ActiveCfg = Release|Any CPU
{FBCF1115-4F77-4706-AE32-B4251561C492}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FBCF1115-4F77-4706-AE32-B4251561C492}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FBCF1115-4F77-4706-AE32-B4251561C492}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{FBCF1115-4F77-4706-AE32-B4251561C492}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{FBCF1115-4F77-4706-AE32-B4251561C492}.Debug|x86.ActiveCfg = Debug|Any CPU
{FBCF1115-4F77-4706-AE32-B4251561C492}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FBCF1115-4F77-4706-AE32-B4251561C492}.Release|Any CPU.Build.0 = Release|Any CPU
{FBCF1115-4F77-4706-AE32-B4251561C492}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{FBCF1115-4F77-4706-AE32-B4251561C492}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{FBCF1115-4F77-4706-AE32-B4251561C492}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion NSpec/Domain/Extensions/DomainExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static IEnumerable<MethodInfo> Methods(this Type type)
var methodInfos = type.GetAbstractBaseClassChainWithClass().SelectMany(t => t.GetMethods(flags));

return methodInfos
.Where(m => !exclusions.Contains(m.Name) && !m.Name.Contains("<") && m.Name.Contains("_"))
.Where(m => !exclusions.Contains(m.Name) && !(m.Name.Contains("<") || m.Name.Contains("$")) && m.Name.Contains("_"))
.Where(m => m.GetParameters().Length == 0)
.Where(m => m.ReturnType == typeof(void)).ToList();
}
Expand Down
29 changes: 29 additions & 0 deletions NSpecSpecs/describe_RunningSpecs/describe_example.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,34 @@ public void passing_status_is_not_passed_when_it_fails()

TheExample("it fails").should_have_failed();
}

class SpecClassWithAnonymouseLambdas : nspec
{
void describe_specs_with_anonymous_lambdas()
{
context["Some context with anonymous lambdas"] = () =>
{
it["has an anonymous lambda"] = () =>
{
};
};
}
}

[Test]
public void finds_and_runs_three_class_level_examples()
{
Run(typeof(SpecClass));

TheExampleCount().should_be(3);
}

[Test]
public void finds_and_runs_only_one_example_ignoring_anonymous_lambdas()
{
Run(typeof(SpecClassWithAnonymouseLambdas));

TheExampleCount().should_be(1);
}
}
}
10 changes: 10 additions & 0 deletions NSpecSpecs/describe_RunningSpecs/when_running_specs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ protected Example TheExample(string name)
return theExample;
}

protected int TheExampleCount()
{
var theExamples = contextCollection
.SelectMany(rootContext => rootContext.AllContexts())
.SelectMany(contexts => contexts.AllExamples())
.Distinct();

return theExamples.Count();
}

protected ContextBuilder builder;
protected ContextCollection contextCollection;
protected ClassContext classContext;
Expand Down
81 changes: 81 additions & 0 deletions NSpecSpecsVB/Describe_RunningSpecs/Describe_Example.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
Imports NSpec
Imports NUnit.Framework
Imports NSpecSpecs
Imports NSpecSpecs.WhenRunningSpecs

Namespace WhenRunningSpecs

<TestFixture()>
<Category("RunningSpecs")>
Public Class DescribeExample
Inherits when_running_specs

Public Class SpecClass
Inherits NSpec.nspec

Sub It_Changes_Status_After_Run()

End Sub

Sub It_Passes()

End Sub

Sub It_Fails()
Throw New Exception()
End Sub
End Class

<Test()>
Sub Execution_Status_Changes_After_Run()
Run(GetType(SpecClass))

Dim ex = TheExample("It Changes Status After Run")

ex.HasRun.should_be_true()
End Sub

<Test()>
Sub Passing_Status_Is_Passed_When_It_Succeeds()
Run(GetType(SpecClass))

TheExample("It Passes").should_have_passed()
End Sub

<Test()>
Sub Passing_Status_Is_Not_Passed_When_It_Fails()
Run(GetType(SpecClass))

TheExample("It Fails").should_have_failed()
End Sub

Public Class SpecClassWithAnonymousLambdas
Inherits NSpec.nspec

Sub Describe_Specs_In_VB_With_Anonymous_Lambdas()
context("Some context with an anonymous Lambda") =
Sub()
it("has an anonymous lambda") = Sub()
End Sub
End Sub
End Sub
End Class

<Test()>
Sub Finds_And_Runs_Three_Class_Level_Examples()
Run(GetType(SpecClass))

TheExampleCount().should_be(3)
End Sub

<Test()>
Sub Finds_Only_One_Example_Ignoring_Anonymous_Lambdas()
Run(GetType(SpecClassWithAnonymousLambdas))

TheExampleCount().should_be(1)
End Sub

End Class

End Namespace

13 changes: 13 additions & 0 deletions NSpecSpecsVB/My Project/Application.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions NSpecSpecsVB/My Project/Application.myapp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MySubMain>false</MySubMain>
<SingleInstance>false</SingleInstance>
<ShutdownMode>0</ShutdownMode>
<EnableVisualStyles>true</EnableVisualStyles>
<AuthenticationMode>0</AuthenticationMode>
<ApplicationType>1</ApplicationType>
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
</MyApplicationData>
35 changes: 35 additions & 0 deletions NSpecSpecsVB/My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices

' General Information about an assembly is controlled through the following
' set of attributes. Change these attribute values to modify the information
' associated with an assembly.

' Review the values of the assembly attributes

<Assembly: AssemblyTitle("NSpecSpecsVB")>
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("Microsoft")>
<Assembly: AssemblyProduct("NSpecSpecsVB")>
<Assembly: AssemblyCopyright("Copyright © Microsoft 2014")>
<Assembly: AssemblyTrademark("")>

<Assembly: ComVisible(False)>

'The following GUID is for the ID of the typelib if this project is exposed to COM
<Assembly: Guid("3e299a57-cabc-41b4-80bd-79cc64f45bc1")>

' Version information for an assembly consists of the following four values:
'
' Major Version
' Minor Version
' Build Number
' Revision
'
' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("1.0.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>
62 changes: 62 additions & 0 deletions NSpecSpecsVB/My Project/Resources.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9bb420a

Please sign in to comment.