Skip to content
Browse files

Created Code Snippet files for Visual Studio 2010 and the install scr…

…ipts. see ./Misc/readme.txt for details

Closes #104
  • Loading branch information...
1 parent e333fb3 commit 07538aeca95633df4f916ba3d973fdb9b9ac2c1f Rainer Schuster committed with agross May 10, 2012
View
25 Misc/CodeSnippets/create_mspec_install_bat.py
@@ -0,0 +1,25 @@
+import os
+from jinja2 import Environment, DictLoader
+
+#TODO: Add command line handling
+vs_version = "2010"
+setup_file_name= 'install_vs' + vs_version + '_snippets.bat'
+source_folder = 'snippets'
+install_folder = '%USERPROFILE%\Documents\Visual Studio '+vs_version+'\Code Snippets\Visual C#\My Code Snippets'
+context = locals()
+
+templates = { setup_file_name :
+ '''
+mkdir "{{install_folder}}" 2> NUL
+{% for file in os.listdir(source_folder) %}
+copy "{{os.path.join(source_folder,file)}}" "{{install_folder}}"
+{%- endfor %}
+pause
+'''}
+
+env = Environment(loader=DictLoader(templates))
+template = env.get_template(setup_file_name)
+content = template.render(context)
+setup_file = open( setup_file_name, 'w')
+setup_file.write(content)
+setup_file.close()
View
13 Misc/CodeSnippets/install_vs2010_snippets.bat
@@ -0,0 +1,13 @@
+
+mkdir "%USERPROFILE%\Documents\Visual Studio 2010\Code Snippets\Visual C#\My Code Snippets" 2> NUL
+
+copy "snippets\bec.snippet" "%USERPROFILE%\Documents\Visual Studio 2010\Code Snippets\Visual C#\My Code Snippets"
+copy "snippets\becex.snippet" "%USERPROFILE%\Documents\Visual Studio 2010\Code Snippets\Visual C#\My Code Snippets"
+copy "snippets\espec.snippet" "%USERPROFILE%\Documents\Visual Studio 2010\Code Snippets\Visual C#\My Code Snippets"
+copy "snippets\est.snippet" "%USERPROFILE%\Documents\Visual Studio 2010\Code Snippets\Visual C#\My Code Snippets"
+copy "snippets\fail.snippet" "%USERPROFILE%\Documents\Visual Studio 2010\Code Snippets\Visual C#\My Code Snippets"
+copy "snippets\it.snippet" "%USERPROFILE%\Documents\Visual Studio 2010\Code Snippets\Visual C#\My Code Snippets"
+copy "snippets\l.snippet" "%USERPROFILE%\Documents\Visual Studio 2010\Code Snippets\Visual C#\My Code Snippets"
+copy "snippets\ll.snippet" "%USERPROFILE%\Documents\Visual Studio 2010\Code Snippets\Visual C#\My Code Snippets"
+copy "snippets\spec.snippet" "%USERPROFILE%\Documents\Visual Studio 2010\Code Snippets\Visual C#\My Code Snippets"
+pause
View
4 Misc/CodeSnippets/readme.txt
@@ -0,0 +1,4 @@
+Code Snippet Files for Visual Studio (tested in VS2010). Created from the ReSharper LiveTemplates from http://therightstuff.de/2010/03/03/MachineSpecifications-Templates-For-ReSharper.aspx
+
+Use and modify `create_mspec_install_bat.py` (defaults to VS2010) if you need to.
+After executing the script an `install_vs[Version]_snippets.bat` file is created in from the content of the `snippets` folder. Execute the `install_vs[Version]_snippets.bat` in order to copy the snippets to your %USERPROFILE% location of Visual Studio.
View
20 Misc/CodeSnippets/snippets/bec.snippet
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
+ <CodeSnippet Format="1.0.0">
+ <Header>
+ <Title>bec</Title>
+ <Shortcut>bec</Shortcut>
+ <Description>Code snippet for creating the Machine.Specifications action (because of)</Description>
+ <Author>Rainer Schuster</Author>
+ <SnippetTypes>
+ <SnippetType>Expansion</SnippetType>
+ </SnippetTypes>
+ </Header>
+ <Snippet>
+ <Code Language="csharp">
+ <![CDATA[Because of =()=> {
+ $end$ };]]>
+ </Code>
+ </Snippet>
+ </CodeSnippet>
+</CodeSnippets>
View
19 Misc/CodeSnippets/snippets/becex.snippet
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
+ <CodeSnippet Format="1.0.0">
+ <Header>
+ <Title>exception handling for mspec (because of)</Title>
+ <Shortcut>becex</Shortcut>
+ <Description>Code snippet for handling the Machine.Specifications exception from the action (because of)</Description>
+ <Author>Rainer Schuster</Author>
+ <SnippetTypes>
+ <SnippetType>Expansion</SnippetType>
+ </SnippetTypes>
+ </Header>
+ <Snippet>
+ <Code Language="csharp">
+ <![CDATA[Because of =()=> { Exception = Catch.Exception( ()=> {$end$ });};]]>
+ </Code>
+ </Snippet>
+ </CodeSnippet>
+</CodeSnippets>
View
40 Misc/CodeSnippets/snippets/espec.snippet
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
+ <CodeSnippet Format="1.0.0">
+ <Header>
+ <Title>espec</Title>
+ <Shortcut>espec</Shortcut>
+ <Description>Code snippet for creating an empty specification (empty scenario)</Description>
+ <Author>Rainer Schuster</Author>
+ <SnippetTypes>
+ <SnippetType>Expansion</SnippetType>
+ </SnippetTypes>
+ </Header>
+ <Snippet>
+ <Declarations>
+ <Literal>
+ <ID>subject</ID>
+ <ToolTip>The subject to be observer and tested</ToolTip>
+ <Default>subject to be observed</Default>
+ </Literal>
+ <Literal>
+ <ID>some_action_is_executed</ID>
+ <ToolTip>describe the action that your customer wants to be performed</ToolTip>
+ <Default>some_action_is_executed</Default>
+ </Literal>
+ <Literal>
+ <ID>observation</ID>
+ <ToolTip>describe the behaviour (reaction) your customer expects </ToolTip>
+ <Default>observation</Default>
+ </Literal>
+ </Declarations>
+ <Code Language="csharp">
+ <![CDATA[[Subject("$subject$")]
+public class when_$some_action_is_executed$
+{
+ It should_$observation$;$end$
+}]]>
+ </Code>
+ </Snippet>
+ </CodeSnippet>
+</CodeSnippets>
View
19 Misc/CodeSnippets/snippets/est.snippet
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
+ <CodeSnippet Format="1.0.0">
+ <Header>
+ <Title>est</Title>
+ <Shortcut>est</Shortcut>
+ <Description>Code snippet for establishing a Machine.Specifications context</Description>
+ <Author>Rainer Schuster</Author>
+ <SnippetTypes>
+ <SnippetType>Expansion</SnippetType>
+ </SnippetTypes>
+ </Header>
+ <Snippet>
+ <Code Language="csharp">
+ <![CDATA[Establish context =()=> { $end$ };]]>
+ </Code>
+ </Snippet>
+ </CodeSnippet>
+</CodeSnippets>
View
21 Misc/CodeSnippets/snippets/fail.snippet
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
+ <CodeSnippet Format="1.0.0">
+ <Header>
+ <Title>fail</Title>
+ <Shortcut>fail</Shortcut>
+ <Description>Code snippet for creating the Machine.Specifications action (because of)</Description>
+ <Author>Rainer Schuster</Author>
+ <SnippetTypes>
+ <SnippetType>Expansion</SnippetType>
+ </SnippetTypes>
+ </Header>
+ <Snippet>
+ <Code Language="csharp">
+ <![CDATA[It should_fail =()=> Exception.ShouldNotBeNull();
+ $end$
+ static Exception Exception;]]>
+ </Code>
+ </Snippet>
+ </CodeSnippet>
+</CodeSnippets>
View
26 Misc/CodeSnippets/snippets/it.snippet
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
+ <CodeSnippet Format="1.0.0">
+ <Header>
+ <Title>it</Title>
+ <Shortcut>it</Shortcut>
+ <Description>Code snippet for creating an Machine.Specifications observation</Description>
+ <Author>Rainer Schuster</Author>
+ <SnippetTypes>
+ <SnippetType>Expansion</SnippetType>
+ </SnippetTypes>
+ </Header>
+ <Snippet>
+ <Declarations>
+ <Literal>
+ <ID>observation</ID>
+ <ToolTip>describe the behaviour (reaction) your customer expects</ToolTip>
+ <Default>observation</Default>
+ </Literal>
+ </Declarations>
+ <Code Language="csharp">
+ <![CDATA[It should_$observation$ =()=> { $end$ };]]>
+ </Code>
+ </Snippet>
+ </CodeSnippet>
+</CodeSnippets>
View
19 Misc/CodeSnippets/snippets/l.snippet
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
+ <CodeSnippet Format="1.0.0">
+ <Header>
+ <Title>lambda expression</Title>
+ <Shortcut>l</Shortcut>
+ <Description>lambda expression</Description>
+ <Author>Rainer Schuster</Author>
+ <SnippetTypes>
+ <SnippetType>Expansion</SnippetType>
+ </SnippetTypes>
+ </Header>
+ <Snippet>
+ <Code Language="csharp">
+ <![CDATA[=()=>$end$;]]>
+ </Code>
+ </Snippet>
+ </CodeSnippet>
+</CodeSnippets>
View
19 Misc/CodeSnippets/snippets/ll.snippet
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
+ <CodeSnippet Format="1.0.0">
+ <Header>
+ <Title>long lambda expression</Title>
+ <Shortcut>ll</Shortcut>
+ <Description>long lambda expression</Description>
+ <Author>Rainer Schuster</Author>
+ <SnippetTypes>
+ <SnippetType>Expansion</SnippetType>
+ </SnippetTypes>
+ </Header>
+ <Snippet>
+ <Code Language="csharp">
+ <![CDATA[=()=>{$end$};]]>
+ </Code>
+ </Snippet>
+ </CodeSnippet>
+</CodeSnippets>
View
46 Misc/CodeSnippets/snippets/spec.snippet
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
+ <CodeSnippet Format="1.0.0">
+ <Header>
+ <Title>spec</Title>
+ <Shortcut>spec</Shortcut>
+ <Description>Code snippet for creating a Machine.Specifications specification</Description>
+ <Author>Rainer Schuster</Author>
+ <SnippetTypes>
+ <SnippetType>Expansion</SnippetType>
+ </SnippetTypes>
+ </Header>
+ <Snippet>
+ <Declarations>
+ <Literal>
+ <ID>subject</ID>
+ <ToolTip>The subject to be observer and tested</ToolTip>
+ <Default>subject to be observed</Default>
+ </Literal>
+ <Literal>
+ <ID>some_action_is_executed</ID>
+ <ToolTip>describe the action that your customer wants to be performed</ToolTip>
+ <Default>some_action_is_executed</Default>
+ </Literal>
+ <Literal>
+ <ID>observation</ID>
+ <ToolTip>describe the behaviour (reaction) your customer expects </ToolTip>
+ <Default>observation</Default>
+ </Literal>
+ </Declarations>
+ <Code Language="csharp">
+ <![CDATA[[Subject("$subject$")]
+public class when_$some_action_is_executed$
+{
+ Establish context =()=> {};
+ Because of =()=> {};
+
+ It should_$observation$ =()=>
+ {
+ $end$
+ };
+}]]>
+ </Code>
+ </Snippet>
+ </CodeSnippet>
+</CodeSnippets>

0 comments on commit 07538ae

Please sign in to comment.
Something went wrong with that request. Please try again.