summaryrefslogtreecommitdiff
path: root/tools/MbUnit/VSSnippets/MbUnitCSharpSnippets/model.snippet
blob: 8ad72c3808d328ebec4a258d66000f838f53d8c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?xml version="1.0"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Model</Title>
      <Author>MbUnit</Author>
      <Description>Expansion snippet for a Model</Description>
      <Shortcut>model</Shortcut>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>namespace</ID>
          <ToolTip>Model namespace</ToolTip>
        </Literal>
        <Literal>
          <ID>type</ID>
          <ToolTip>Modelled type</ToolTip>
          <Default>Put the modelled type here</Default>
        </Literal>
        <Literal>
          <ID>basetype</ID>
          <ToolTip>Modelled Base Type</ToolTip>
          <Default>Object</Default>
        </Literal>
      </Declarations>
      <Code Language="csharp"><![CDATA[using System;
using TestFu;
using TestFu.Models;

namespace $namespace$
{
    /// <summary>
    /// A <see cref="IModel"/> implementation for the 
    /// <see cref="$type$"/> type.
    /// </summary>
    [Model(typeof($type$))]
    // [State("Put a state name here")]
    // [SubModel("Put a submodel name here")]
    public class $type$Model : $basetype$Model
    {
        #region Constructors
        /// <summary>
        /// Initializes a new <see cref="$name$Model"/> instance.
        /// </summary>
        public $type$Model()
        :base()
        {}
    
        /// <summary>
        /// Initializes a new <see cref="$name$Model"/> instance
        /// to model the <paramref name="modelledType"/> type.
        /// </summary>
        /// <param name="modelledType">
        /// Target <see cref="Type"/> of the model
        /// </param>
        public $type$Model(Type modelledType)
        :base(modelledType)
        {
            if (!typeof($type$).IsAssignableFrom(modelledType))
                throw new ArgumentException("$type$ is not assignable from "+modelledType.FullName,"modelledType");            
        }    
        #endregion
    
        #region Transitions
        [Transition]
        public void SampleTransition($type$ target)
        {
            throw new NotImplemented();
        }
     
        /// <summary>
        /// Gets the active <see cref="ITransition"/> instance for
        /// current <paramref name="target"/>.
        /// </summary>
        /// <param name="transitions">
        /// Collection of active <see cref="ITransition"/> names
        /// </param>
        /// <param name="target">
        /// Current tested instance
        /// </param>
        protected override void GetActiveTransitions(
            ITransitionNameCollection transitions,
            Object target
            )
        {
            base.GetActiveTransitions(transitions,target);
            $type$ current = ($type$)target;
    
            $end$
        }   
        #endregion
    }
}
	]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>