##// END OF EJS Templates
ported tests to mono
cin -
r77:91362ffbecf8 v2
parent child
Show More
@@ -0,0 +1,80
1 <?xml version="1.0" encoding="utf-8"?>
2 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 <PropertyGroup>
4 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6 <ProductVersion>8.0.30703</ProductVersion>
7 <SchemaVersion>2.0</SchemaVersion>
8 <ProjectGuid>{2BD05F84-E067-4B87-9477-FDC2676A21C6}</ProjectGuid>
9 <OutputType>Library</OutputType>
10 <RootNamespace>Implab.Fx.Test</RootNamespace>
11 <AssemblyName>Implab.Fx.Test</AssemblyName>
12 <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13 </PropertyGroup>
14 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
15 <DebugSymbols>true</DebugSymbols>
16 <DebugType>full</DebugType>
17 <Optimize>false</Optimize>
18 <OutputPath>bin\Debug</OutputPath>
19 <DefineConstants>DEBUG;MONO</DefineConstants>
20 <ErrorReport>prompt</ErrorReport>
21 <WarningLevel>4</WarningLevel>
22 <ConsolePause>false</ConsolePause>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25 <Optimize>true</Optimize>
26 <OutputPath>bin\Release</OutputPath>
27 <ErrorReport>prompt</ErrorReport>
28 <WarningLevel>4</WarningLevel>
29 <ConsolePause>false</ConsolePause>
30 <DefineConstants>MONO</DefineConstants>
31 </PropertyGroup>
32 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' ">
33 <DebugSymbols>true</DebugSymbols>
34 <DebugType>full</DebugType>
35 <Optimize>false</Optimize>
36 <OutputPath>bin\Debug</OutputPath>
37 <DefineConstants>DEBUG;TRACE;NET_4_5;MONO</DefineConstants>
38 <ErrorReport>prompt</ErrorReport>
39 <WarningLevel>4</WarningLevel>
40 <ConsolePause>false</ConsolePause>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' ">
43 <Optimize>true</Optimize>
44 <OutputPath>bin\Release</OutputPath>
45 <DefineConstants>NET_4_5;MONO</DefineConstants>
46 <ErrorReport>prompt</ErrorReport>
47 <WarningLevel>4</WarningLevel>
48 <ConsolePause>false</ConsolePause>
49 </PropertyGroup>
50 <ItemGroup>
51 <Reference Include="System" />
52 <Reference Include="nunit.framework" />
53 <Reference Include="System.Windows.Forms" />
54 <Reference Include="System.Drawing" />
55 <Reference Include="System.Data" />
56 </ItemGroup>
57 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
58 <ItemGroup>
59 <ProjectReference Include="..\Implab.Fx\Implab.Fx.csproj">
60 <Project>{06E706F8-6881-43EB-927E-FFC503AF6ABC}</Project>
61 <Name>Implab.Fx</Name>
62 </ProjectReference>
63 <ProjectReference Include="..\Implab\Implab.csproj">
64 <Project>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</Project>
65 <Name>Implab</Name>
66 </ProjectReference>
67 </ItemGroup>
68 <ItemGroup>
69 <Compile Include="OverlayTest.cs" />
70 <Compile Include="Properties\AssemblyInfo.cs" />
71 <Compile Include="Sample\MainForm.Designer.cs" />
72 <Compile Include="Sample\MainForm.cs" />
73 <Compile Include="Sample\OverlayForm.Designer.cs" />
74 <Compile Include="Sample\OverlayForm.cs" />
75 </ItemGroup>
76 <ItemGroup>
77 <None Include="Sample\MainForm.resx" />
78 <None Include="Sample\OverlayForm.resx" />
79 </ItemGroup>
80 </Project> No newline at end of file
@@ -0,0 +1,66
1 <?xml version="1.0" encoding="utf-8"?>
2 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 <PropertyGroup>
4 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6 <ProductVersion>8.0.30703</ProductVersion>
7 <SchemaVersion>2.0</SchemaVersion>
8 <ProjectGuid>{2BD05F84-E067-4B87-9477-FDC2676A21C6}</ProjectGuid>
9 <OutputType>Library</OutputType>
10 <RootNamespace>Implab.Test</RootNamespace>
11 <AssemblyName>Implab.Test</AssemblyName>
12 <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13 </PropertyGroup>
14 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
15 <DebugSymbols>true</DebugSymbols>
16 <DebugType>full</DebugType>
17 <Optimize>false</Optimize>
18 <OutputPath>bin\Debug</OutputPath>
19 <DefineConstants>DEBUG;MONO</DefineConstants>
20 <ErrorReport>prompt</ErrorReport>
21 <WarningLevel>4</WarningLevel>
22 <ConsolePause>false</ConsolePause>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25 <Optimize>true</Optimize>
26 <OutputPath>bin\Release</OutputPath>
27 <ErrorReport>prompt</ErrorReport>
28 <WarningLevel>4</WarningLevel>
29 <ConsolePause>false</ConsolePause>
30 <DefineConstants>MONO</DefineConstants>
31 </PropertyGroup>
32 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' ">
33 <DebugSymbols>true</DebugSymbols>
34 <DebugType>full</DebugType>
35 <Optimize>false</Optimize>
36 <OutputPath>bin\Debug</OutputPath>
37 <DefineConstants>DEBUG;TRACE;NET_4_5;MONO</DefineConstants>
38 <ErrorReport>prompt</ErrorReport>
39 <WarningLevel>4</WarningLevel>
40 <ConsolePause>false</ConsolePause>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' ">
43 <Optimize>true</Optimize>
44 <OutputPath>bin\Release</OutputPath>
45 <DefineConstants>NET_4_5;MONO</DefineConstants>
46 <ErrorReport>prompt</ErrorReport>
47 <WarningLevel>4</WarningLevel>
48 <ConsolePause>false</ConsolePause>
49 </PropertyGroup>
50 <ItemGroup>
51 <Reference Include="System" />
52 <Reference Include="nunit.framework" />
53 </ItemGroup>
54 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
55 <ItemGroup>
56 <Compile Include="AsyncTests.cs" />
57 <Compile Include="PromiseHelper.cs" />
58 <Compile Include="Properties\AssemblyInfo.cs" />
59 </ItemGroup>
60 <ItemGroup>
61 <ProjectReference Include="..\Implab\Implab.csproj">
62 <Project>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</Project>
63 <Name>Implab</Name>
64 </ProjectReference>
65 </ItemGroup>
66 </Project> No newline at end of file
@@ -0,0 +1,290
1 
2 Microsoft Visual Studio Solution File, Format Version 11.00
3 # Visual Studio 2010
4 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Implab", "Implab\Implab.csproj", "{F550F1F8-8746-4AD0-9614-855F4C4B7F05}"
5 EndProject
6 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CE8D8D18-437A-445C-B662-4C2CE79A76F6}"
7 ProjectSection(SolutionItems) = preProject
8 Implab.vsmdi = Implab.vsmdi
9 Local.testsettings = Local.testsettings
10 TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings
11 EndProjectSection
12 EndProject
13 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Implab.Fx", "Implab.Fx\Implab.Fx.csproj", "{06E706F8-6881-43EB-927E-FFC503AF6ABC}"
14 EndProject
15 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{BCA337C3-BFDC-4825-BBDB-E6D467E4E452}"
16 EndProject
17 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Implab.Test.mono", "Implab.Test\Implab.Test.mono.csproj", "{2BD05F84-E067-4B87-9477-FDC2676A21C6}"
18 EndProject
19 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Implab.Fx.Test.mono", "Implab.Fx.Test\Implab.Fx.Test.mono.csproj", "{2BD05F84-E067-4B87-9477-FDC2676A21C6}"
20 EndProject
21 Global
22 GlobalSection(SolutionConfigurationPlatforms) = preSolution
23 Debug|Any CPU = Debug|Any CPU
24 Release|Any CPU = Release|Any CPU
25 Debug 4.5|Any CPU = Debug 4.5|Any CPU
26 Release 4.5|Any CPU = Release 4.5|Any CPU
27 EndGlobalSection
28 GlobalSection(ProjectConfigurationPlatforms) = postSolution
29 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Debug 4.5|Any CPU.ActiveCfg = Debug 4.5|Any CPU
30 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Debug 4.5|Any CPU.Build.0 = Debug 4.5|Any CPU
31 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Debug|Any CPU.Build.0 = Debug|Any CPU
33 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Release 4.5|Any CPU.ActiveCfg = Release 4.5|Any CPU
34 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Release 4.5|Any CPU.Build.0 = Release 4.5|Any CPU
35 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Release|Any CPU.ActiveCfg = Release|Any CPU
36 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Release|Any CPU.Build.0 = Release|Any CPU
37 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Debug 4.5|Any CPU.ActiveCfg = Debug 4.5|Any CPU
38 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Debug 4.5|Any CPU.ActiveCfg = Debug 4.5|Any CPU
39 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Debug 4.5|Any CPU.Build.0 = Debug 4.5|Any CPU
40 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Debug 4.5|Any CPU.Build.0 = Debug 4.5|Any CPU
41 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
42 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
43 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
44 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
45 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Release 4.5|Any CPU.ActiveCfg = Release 4.5|Any CPU
46 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Release 4.5|Any CPU.ActiveCfg = Release 4.5|Any CPU
47 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Release 4.5|Any CPU.Build.0 = Release 4.5|Any CPU
48 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Release 4.5|Any CPU.Build.0 = Release 4.5|Any CPU
49 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
50 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
51 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Release|Any CPU.Build.0 = Release|Any CPU
52 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Release|Any CPU.Build.0 = Release|Any CPU
53 {2F31E405-E267-4195-A05D-574093C21209}.Debug 4.5|Any CPU.ActiveCfg = Debug 4.5|Any CPU
54 {2F31E405-E267-4195-A05D-574093C21209}.Debug 4.5|Any CPU.Build.0 = Debug 4.5|Any CPU
55 {2F31E405-E267-4195-A05D-574093C21209}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
56 {2F31E405-E267-4195-A05D-574093C21209}.Debug|Any CPU.Build.0 = Debug|Any CPU
57 {2F31E405-E267-4195-A05D-574093C21209}.Release 4.5|Any CPU.ActiveCfg = Release 4.5|Any CPU
58 {2F31E405-E267-4195-A05D-574093C21209}.Release 4.5|Any CPU.Build.0 = Release 4.5|Any CPU
59 {2F31E405-E267-4195-A05D-574093C21209}.Release|Any CPU.ActiveCfg = Release|Any CPU
60 {2F31E405-E267-4195-A05D-574093C21209}.Release|Any CPU.Build.0 = Release|Any CPU
61 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Debug 4.5|Any CPU.ActiveCfg = Debug 4.5|Any CPU
62 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Debug 4.5|Any CPU.Build.0 = Debug 4.5|Any CPU
63 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
64 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
65 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Release 4.5|Any CPU.ActiveCfg = Release 4.5|Any CPU
66 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Release 4.5|Any CPU.Build.0 = Release 4.5|Any CPU
67 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
68 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Release|Any CPU.Build.0 = Release|Any CPU
69 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Debug 4.5|Any CPU.ActiveCfg = Debug 4.5|Any CPU
70 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Debug 4.5|Any CPU.Build.0 = Debug 4.5|Any CPU
71 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
72 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Debug|Any CPU.Build.0 = Debug|Any CPU
73 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Release 4.5|Any CPU.ActiveCfg = Release 4.5|Any CPU
74 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Release 4.5|Any CPU.Build.0 = Release 4.5|Any CPU
75 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Release|Any CPU.ActiveCfg = Release|Any CPU
76 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Release|Any CPU.Build.0 = Release|Any CPU
77 EndGlobalSection
78 GlobalSection(NestedProjects) = preSolution
79 {2BD05F84-E067-4B87-9477-FDC2676A21C6} = {BCA337C3-BFDC-4825-BBDB-E6D467E4E452}
80 {2BD05F84-E067-4B87-9477-FDC2676A21C6} = {BCA337C3-BFDC-4825-BBDB-E6D467E4E452}
81 EndGlobalSection
82 GlobalSection(MonoDevelopProperties) = preSolution
83 StartupItem = Implab\Implab.csproj
84 Policies = $0
85 $0.CSharpFormattingPolicy = $1
86 $1.IndentSwitchBody = True
87 $1.NamespaceBraceStyle = EndOfLine
88 $1.ClassBraceStyle = EndOfLine
89 $1.InterfaceBraceStyle = EndOfLine
90 $1.StructBraceStyle = EndOfLine
91 $1.EnumBraceStyle = EndOfLine
92 $1.MethodBraceStyle = EndOfLine
93 $1.ConstructorBraceStyle = EndOfLine
94 $1.DestructorBraceStyle = EndOfLine
95 $1.BeforeMethodDeclarationParentheses = False
96 $1.BeforeMethodCallParentheses = False
97 $1.BeforeConstructorDeclarationParentheses = False
98 $1.NewLineBeforeConstructorInitializerColon = NewLine
99 $1.NewLineAfterConstructorInitializerColon = SameLine
100 $1.BeforeIndexerDeclarationBracket = False
101 $1.BeforeDelegateDeclarationParentheses = False
102 $1.NewParentheses = False
103 $1.SpacesBeforeBrackets = False
104 $1.inheritsSet = Mono
105 $1.inheritsScope = text/x-csharp
106 $1.scope = text/x-csharp
107 $0.TextStylePolicy = $2
108 $2.FileWidth = 120
109 $2.EolMarker = Unix
110 $2.inheritsSet = VisualStudio
111 $2.inheritsScope = text/plain
112 $2.scope = text/x-csharp
113 $0.DotNetNamingPolicy = $3
114 $3.DirectoryNamespaceAssociation = PrefixedHierarchical
115 $3.ResourceNamePolicy = MSBuild
116 $0.TextStylePolicy = $4
117 $4.FileWidth = 120
118 $4.TabsToSpaces = False
119 $4.inheritsSet = VisualStudio
120 $4.inheritsScope = text/plain
121 $4.scope = application/xml
122 $0.XmlFormattingPolicy = $5
123 $5.inheritsSet = Mono
124 $5.inheritsScope = application/xml
125 $5.scope = application/xml
126 $0.TextStylePolicy = $6
127 $6.FileWidth = 120
128 $6.TabsToSpaces = False
129 $6.inheritsSet = VisualStudio
130 $6.inheritsScope = text/plain
131 $6.scope = text/plain
132 $0.NameConventionPolicy = $7
133 $7.Rules = $8
134 $8.NamingRule = $9
135 $9.Name = Namespaces
136 $9.AffectedEntity = Namespace
137 $9.VisibilityMask = VisibilityMask
138 $9.NamingStyle = PascalCase
139 $9.IncludeInstanceMembers = True
140 $9.IncludeStaticEntities = True
141 $8.NamingRule = $10
142 $10.Name = Types
143 $10.AffectedEntity = Class, Struct, Enum, Delegate
144 $10.VisibilityMask = VisibilityMask
145 $10.NamingStyle = PascalCase
146 $10.IncludeInstanceMembers = True
147 $10.IncludeStaticEntities = True
148 $8.NamingRule = $11
149 $11.Name = Interfaces
150 $11.RequiredPrefixes = $12
151 $12.String = I
152 $11.AffectedEntity = Interface
153 $11.VisibilityMask = VisibilityMask
154 $11.NamingStyle = PascalCase
155 $11.IncludeInstanceMembers = True
156 $11.IncludeStaticEntities = True
157 $8.NamingRule = $13
158 $13.Name = Attributes
159 $13.RequiredSuffixes = $14
160 $14.String = Attribute
161 $13.AffectedEntity = CustomAttributes
162 $13.VisibilityMask = VisibilityMask
163 $13.NamingStyle = PascalCase
164 $13.IncludeInstanceMembers = True
165 $13.IncludeStaticEntities = True
166 $8.NamingRule = $15
167 $15.Name = Event Arguments
168 $15.RequiredSuffixes = $16
169 $16.String = EventArgs
170 $15.AffectedEntity = CustomEventArgs
171 $15.VisibilityMask = VisibilityMask
172 $15.NamingStyle = PascalCase
173 $15.IncludeInstanceMembers = True
174 $15.IncludeStaticEntities = True
175 $8.NamingRule = $17
176 $17.Name = Exceptions
177 $17.RequiredSuffixes = $18
178 $18.String = Exception
179 $17.AffectedEntity = CustomExceptions
180 $17.VisibilityMask = VisibilityMask
181 $17.NamingStyle = PascalCase
182 $17.IncludeInstanceMembers = True
183 $17.IncludeStaticEntities = True
184 $8.NamingRule = $19
185 $19.Name = Methods
186 $19.AffectedEntity = Methods
187 $19.VisibilityMask = VisibilityMask
188 $19.NamingStyle = PascalCase
189 $19.IncludeInstanceMembers = True
190 $19.IncludeStaticEntities = True
191 $8.NamingRule = $20
192 $20.Name = Static Readonly Fields
193 $20.AffectedEntity = ReadonlyField
194 $20.VisibilityMask = Internal, Protected, Public
195 $20.NamingStyle = PascalCase
196 $20.IncludeInstanceMembers = False
197 $20.IncludeStaticEntities = True
198 $8.NamingRule = $21
199 $21.Name = Fields (Non Private)
200 $21.AffectedEntity = Field
201 $21.VisibilityMask = Internal, Public
202 $21.NamingStyle = CamelCase
203 $21.IncludeInstanceMembers = True
204 $21.IncludeStaticEntities = True
205 $8.NamingRule = $22
206 $22.Name = ReadOnly Fields (Non Private)
207 $22.AffectedEntity = ReadonlyField
208 $22.VisibilityMask = Internal, Public
209 $22.NamingStyle = CamelCase
210 $22.IncludeInstanceMembers = True
211 $22.IncludeStaticEntities = False
212 $8.NamingRule = $23
213 $23.Name = Fields (Private)
214 $23.RequiredPrefixes = $24
215 $24.String = m_
216 $23.AffectedEntity = Field, ReadonlyField
217 $23.VisibilityMask = Private, Protected
218 $23.NamingStyle = CamelCase
219 $23.IncludeInstanceMembers = True
220 $23.IncludeStaticEntities = False
221 $8.NamingRule = $25
222 $25.Name = Static Fields (Private)
223 $25.RequiredPrefixes = $26
224 $26.String = _
225 $25.AffectedEntity = Field
226 $25.VisibilityMask = Private
227 $25.NamingStyle = CamelCase
228 $25.IncludeInstanceMembers = False
229 $25.IncludeStaticEntities = True
230 $8.NamingRule = $27
231 $27.Name = ReadOnly Fields (Private)
232 $27.RequiredPrefixes = $28
233 $28.String = m_
234 $27.AffectedEntity = ReadonlyField
235 $27.VisibilityMask = Private, Protected
236 $27.NamingStyle = CamelCase
237 $27.IncludeInstanceMembers = True
238 $27.IncludeStaticEntities = False
239 $8.NamingRule = $29
240 $29.Name = Constant Fields
241 $29.AffectedEntity = ConstantField
242 $29.VisibilityMask = VisibilityMask
243 $29.NamingStyle = AllUpper
244 $29.IncludeInstanceMembers = True
245 $29.IncludeStaticEntities = True
246 $8.NamingRule = $30
247 $30.Name = Properties
248 $30.AffectedEntity = Property
249 $30.VisibilityMask = VisibilityMask
250 $30.NamingStyle = PascalCase
251 $30.IncludeInstanceMembers = True
252 $30.IncludeStaticEntities = True
253 $8.NamingRule = $31
254 $31.Name = Events
255 $31.AffectedEntity = Event
256 $31.VisibilityMask = VisibilityMask
257 $31.NamingStyle = PascalCase
258 $31.IncludeInstanceMembers = True
259 $31.IncludeStaticEntities = True
260 $8.NamingRule = $32
261 $32.Name = Enum Members
262 $32.AffectedEntity = EnumMember
263 $32.VisibilityMask = VisibilityMask
264 $32.NamingStyle = PascalCase
265 $32.IncludeInstanceMembers = True
266 $32.IncludeStaticEntities = True
267 $8.NamingRule = $33
268 $33.Name = Parameters
269 $33.AffectedEntity = Parameter, LocalVariable
270 $33.VisibilityMask = VisibilityMask
271 $33.NamingStyle = CamelCase
272 $33.IncludeInstanceMembers = True
273 $33.IncludeStaticEntities = True
274 $8.NamingRule = $34
275 $34.Name = Type Parameters
276 $34.RequiredPrefixes = $35
277 $35.String = T
278 $34.AffectedEntity = TypeParameter
279 $34.VisibilityMask = VisibilityMask
280 $34.NamingStyle = PascalCase
281 $34.IncludeInstanceMembers = True
282 $34.IncludeStaticEntities = True
283 EndGlobalSection
284 GlobalSection(TestCaseManagementSettings) = postSolution
285 CategoryFile = Implab.vsmdi
286 EndGlobalSection
287 GlobalSection(SolutionProperties) = preSolution
288 HideSolutionNode = FALSE
289 EndGlobalSection
290 EndGlobal
@@ -1,35 +1,38
1 using System;
1 using System.Windows.Forms;
2 using System.Text;
2 using Implab.Fx.Test.Sample;
3 using System.Collections.Generic;
3 using Implab.Fx;
4 using System.Linq;
4
5 #if MONO
6
7 using NUnit.Framework;
8 using TestClassAttribute = NUnit.Framework.TestFixtureAttribute;
9 using TestMethod = NUnit.Framework.TestAttribute;
10
11 #else
12
5 using Microsoft.VisualStudio.TestTools.UnitTesting;
13 using Microsoft.VisualStudio.TestTools.UnitTesting;
6 using System.Windows.Forms;
14
7 using Implab.Fx.Test.Sample;
15 #endif
8 using System.Drawing;
9 using Implab.Fx;
10
16
11 namespace Implab.Fx.Test
17 namespace Implab.Fx.Test
12 {
18 {
13 [TestClass]
19 [TestClass]
14 public class OverlayTest
20 public class OverlayTest
15 {
21 {
16 [TestMethod]
22 [TestMethod]
17 public void TestMethod1()
23 public void TestMethod1()
18 {
24 {
19 var mainForm = new MainForm();
25 var mainForm = new MainForm();
20
26
21 mainForm.ButtonEvent += (sender, args) =>
27 mainForm.ButtonEvent += (sender, args) =>
22 {
28 {
23 var overlay = new OverlayForm();
29 var overlay = new OverlayForm();
24 mainForm.OverlayFadeIn(overlay).Then(
30 mainForm.OverlayFadeIn(overlay).Then(
25 o => o.ButtonEvent += (s2, args2) =>
31 o => o.ButtonEvent += (s2, args2) => o.CloseFadeOut()
26 {
27 o.CloseFadeOut();
28 }
29 );
32 );
30 };
33 };
31
34
32 Application.Run(mainForm);
35 Application.Run(mainForm);
33 }
36 }
34 }
37 }
35 }
38 }
@@ -1,423 +1,434
1 using System;
1 using System;
2 using Microsoft.VisualStudio.TestTools.UnitTesting;
3 using System.Reflection;
2 using System.Reflection;
4 using System.Threading;
3 using System.Threading;
5 using Implab.Parallels;
4 using Implab.Parallels;
6
5
6 #if MONO
7
8 using NUnit.Framework;
9 using TestClassAttribute = NUnit.Framework.TestFixtureAttribute;
10 using TestMethod = NUnit.Framework.TestAttribute;
11
12 #else
13
14 using Microsoft.VisualStudio.TestTools.UnitTesting;
15
16 #endif
17
7 namespace Implab.Test {
18 namespace Implab.Test {
8 [TestClass]
19 [TestClass]
9 public class AsyncTests {
20 public class AsyncTests {
10 [TestMethod]
21 [TestMethod]
11 public void ResolveTest() {
22 public void ResolveTest() {
12 int res = -1;
23 int res = -1;
13 var p = new Promise<int>();
24 var p = new Promise<int>();
14 p.Then(x => res = x);
25 p.Then(x => res = x);
15 p.Resolve(100);
26 p.Resolve(100);
16
27
17 Assert.AreEqual(100, res);
28 Assert.AreEqual(100, res);
18 }
29 }
19
30
20 [TestMethod]
31 [TestMethod]
21 public void RejectTest() {
32 public void RejectTest() {
22 int res = -1;
33 int res = -1;
23 Exception err = null;
34 Exception err = null;
24
35
25 var p = new Promise<int>();
36 var p = new Promise<int>();
26 p.Then(
37 p.Then(
27 x => res = x,
38 x => res = x,
28 e => {
39 e => {
29 err = e;
40 err = e;
30 return -2;
41 return -2;
31 }
42 }
32 );
43 );
33 p.Reject(new ApplicationException("error"));
44 p.Reject(new ApplicationException("error"));
34
45
35 Assert.AreEqual(res, -1);
46 Assert.AreEqual(res, -1);
36 Assert.AreEqual(err.Message, "error");
47 Assert.AreEqual(err.Message, "error");
37
48
38 }
49 }
39
50
40 [TestMethod]
51 [TestMethod]
41 public void CancelExceptionTest() {
52 public void CancelExceptionTest() {
42 var p = new Promise<bool>();
53 var p = new Promise<bool>();
43 p.Cancel();
54 p.Cancel();
44
55
45 var p2 = p.Cancelled(() => {
56 var p2 = p.Cancelled(() => {
46 throw new ApplicationException("CANCELLED");
57 throw new ApplicationException("CANCELLED");
47 });
58 });
48
59
49 try {
60 try {
50 p2.Join();
61 p2.Join();
51 Assert.Fail();
62 Assert.Fail();
52 } catch (ApplicationException err) {
63 } catch (ApplicationException err) {
53 Assert.AreEqual("CANCELLED", err.InnerException.Message);
64 Assert.AreEqual("CANCELLED", err.InnerException.Message);
54 }
65 }
55
66
56 }
67 }
57
68
58 [TestMethod]
69 [TestMethod]
59 public void ContinueOnCancelTest() {
70 public void ContinueOnCancelTest() {
60 var p = new Promise<bool>();
71 var p = new Promise<bool>();
61 p.Cancel();
72 p.Cancel();
62
73
63 var p2 = p
74 var p2 = p
64 .Cancelled(() => {
75 .Cancelled(() => {
65 throw new ApplicationException("CANCELLED");
76 throw new ApplicationException("CANCELLED");
66 })
77 })
67 .Error(e => true);
78 .Error(e => true);
68
79
69 Assert.AreEqual(true, p2.Join());
80 Assert.AreEqual(true, p2.Join());
70 }
81 }
71
82
72 [TestMethod]
83 [TestMethod]
73 public void JoinSuccessTest() {
84 public void JoinSuccessTest() {
74 var p = new Promise<int>();
85 var p = new Promise<int>();
75 p.Resolve(100);
86 p.Resolve(100);
76 Assert.AreEqual(p.Join(), 100);
87 Assert.AreEqual(p.Join(), 100);
77 }
88 }
78
89
79 [TestMethod]
90 [TestMethod]
80 public void JoinFailTest() {
91 public void JoinFailTest() {
81 var p = new Promise<int>();
92 var p = new Promise<int>();
82 p.Reject(new ApplicationException("failed"));
93 p.Reject(new ApplicationException("failed"));
83
94
84 try {
95 try {
85 p.Join();
96 p.Join();
86 throw new ApplicationException("WRONG!");
97 throw new ApplicationException("WRONG!");
87 } catch (TargetInvocationException err) {
98 } catch (TargetInvocationException err) {
88 Assert.AreEqual(err.InnerException.Message, "failed");
99 Assert.AreEqual(err.InnerException.Message, "failed");
89 } catch {
100 } catch {
90 Assert.Fail("Got wrong excaption");
101 Assert.Fail("Got wrong excaption");
91 }
102 }
92 }
103 }
93
104
94 [TestMethod]
105 [TestMethod]
95 public void MapTest() {
106 public void MapTest() {
96 var p = new Promise<int>();
107 var p = new Promise<int>();
97
108
98 var p2 = p.Then(x => x.ToString());
109 var p2 = p.Then(x => x.ToString());
99 p.Resolve(100);
110 p.Resolve(100);
100
111
101 Assert.AreEqual(p2.Join(), "100");
112 Assert.AreEqual(p2.Join(), "100");
102 }
113 }
103
114
104 [TestMethod]
115 [TestMethod]
105 public void FixErrorTest() {
116 public void FixErrorTest() {
106 var p = new Promise<int>();
117 var p = new Promise<int>();
107
118
108 var p2 = p.Error(e => 101);
119 var p2 = p.Error(e => 101);
109
120
110 p.Reject(new Exception());
121 p.Reject(new Exception());
111
122
112 Assert.AreEqual(p2.Join(), 101);
123 Assert.AreEqual(p2.Join(), 101);
113 }
124 }
114
125
115 [TestMethod]
126 [TestMethod]
116 public void ChainTest() {
127 public void ChainTest() {
117 var p1 = new Promise<int>();
128 var p1 = new Promise<int>();
118
129
119 var p3 = p1.Chain(x => {
130 var p3 = p1.Chain(x => {
120 var p2 = new Promise<string>();
131 var p2 = new Promise<string>();
121 p2.Resolve(x.ToString());
132 p2.Resolve(x.ToString());
122 return p2;
133 return p2;
123 });
134 });
124
135
125 p1.Resolve(100);
136 p1.Resolve(100);
126
137
127 Assert.AreEqual(p3.Join(), "100");
138 Assert.AreEqual(p3.Join(), "100");
128 }
139 }
129
140
130 [TestMethod]
141 [TestMethod]
131 public void PoolTest() {
142 public void PoolTest() {
132 var pid = Thread.CurrentThread.ManagedThreadId;
143 var pid = Thread.CurrentThread.ManagedThreadId;
133 var p = AsyncPool.Invoke(() => Thread.CurrentThread.ManagedThreadId);
144 var p = AsyncPool.Invoke(() => Thread.CurrentThread.ManagedThreadId);
134
145
135 Assert.AreNotEqual(pid, p.Join());
146 Assert.AreNotEqual(pid, p.Join());
136 }
147 }
137
148
138 [TestMethod]
149 [TestMethod]
139 public void WorkerPoolSizeTest() {
150 public void WorkerPoolSizeTest() {
140 var pool = new WorkerPool(5, 10, 0);
151 var pool = new WorkerPool(5, 10, 0);
141
152
142 Assert.AreEqual(5, pool.PoolSize);
153 Assert.AreEqual(5, pool.PoolSize);
143
154
144 pool.Invoke(() => { Thread.Sleep(100000000); return 10; });
155 pool.Invoke(() => { Thread.Sleep(100000000); return 10; });
145 pool.Invoke(() => { Thread.Sleep(100000000); return 10; });
156 pool.Invoke(() => { Thread.Sleep(100000000); return 10; });
146 pool.Invoke(() => { Thread.Sleep(100000000); return 10; });
157 pool.Invoke(() => { Thread.Sleep(100000000); return 10; });
147
158
148 Assert.AreEqual(5, pool.PoolSize);
159 Assert.AreEqual(5, pool.PoolSize);
149
160
150 for (int i = 0; i < 100; i++)
161 for (int i = 0; i < 100; i++)
151 pool.Invoke(() => { Thread.Sleep(100000000); return 10; });
162 pool.Invoke(() => { Thread.Sleep(100000000); return 10; });
152 Thread.Sleep(200);
163 Thread.Sleep(200);
153 Assert.AreEqual(10, pool.PoolSize);
164 Assert.AreEqual(10, pool.PoolSize);
154
165
155 pool.Dispose();
166 pool.Dispose();
156 }
167 }
157
168
158 [TestMethod]
169 [TestMethod]
159 public void WorkerPoolCorrectTest() {
170 public void WorkerPoolCorrectTest() {
160 var pool = new WorkerPool(0,1000,100);
171 var pool = new WorkerPool(0,1000,100);
161
172
162 int iterations = 1000;
173 const int iterations = 1000;
163 int pending = iterations;
174 int pending = iterations;
164 var stop = new ManualResetEvent(false);
175 var stop = new ManualResetEvent(false);
165
176
166 var count = 0;
177 var count = 0;
167 for (int i = 0; i < iterations; i++) {
178 for (int i = 0; i < iterations; i++) {
168 pool
179 pool
169 .Invoke(() => 1)
180 .Invoke(() => 1)
170 .Then(x => Interlocked.Add(ref count, x))
181 .Then(x => Interlocked.Add(ref count, x))
171 .Then(x => Math.Log10(x))
182 .Then(x => Math.Log10(x))
172 .Anyway(() => {
183 .Anyway(() => {
173 Interlocked.Decrement(ref pending);
184 Interlocked.Decrement(ref pending);
174 if (pending == 0)
185 if (pending == 0)
175 stop.Set();
186 stop.Set();
176 });
187 });
177 }
188 }
178
189
179 stop.WaitOne();
190 stop.WaitOne();
180
191
181 Assert.AreEqual(iterations, count);
192 Assert.AreEqual(iterations, count);
182 Console.WriteLine("Max threads: {0}", pool.MaxRunningThreads);
193 Console.WriteLine("Max threads: {0}", pool.MaxRunningThreads);
183 pool.Dispose();
194 pool.Dispose();
184
195
185 }
196 }
186
197
187 [TestMethod]
198 [TestMethod]
188 public void WorkerPoolDisposeTest() {
199 public void WorkerPoolDisposeTest() {
189 var pool = new WorkerPool(5, 20);
200 var pool = new WorkerPool(5, 20);
190 Assert.AreEqual(5, pool.PoolSize);
201 Assert.AreEqual(5, pool.PoolSize);
191 pool.Dispose();
202 pool.Dispose();
192 Thread.Sleep(500);
203 Thread.Sleep(500);
193 Assert.AreEqual(0, pool.PoolSize);
204 Assert.AreEqual(0, pool.PoolSize);
194 pool.Dispose();
205 pool.Dispose();
195 }
206 }
196
207
197 [TestMethod]
208 [TestMethod]
198 public void MTQueueTest() {
209 public void MTQueueTest() {
199 var queue = new MTQueue<int>();
210 var queue = new MTQueue<int>();
200 int res;
211 int res;
201
212
202 queue.Enqueue(10);
213 queue.Enqueue(10);
203 Assert.IsTrue(queue.TryDequeue(out res));
214 Assert.IsTrue(queue.TryDequeue(out res));
204 Assert.AreEqual(10, res);
215 Assert.AreEqual(10, res);
205 Assert.IsFalse(queue.TryDequeue(out res));
216 Assert.IsFalse(queue.TryDequeue(out res));
206
217
207 for (int i = 0; i < 1000; i++)
218 for (int i = 0; i < 1000; i++)
208 queue.Enqueue(i);
219 queue.Enqueue(i);
209
220
210 for (int i = 0; i < 1000; i++) {
221 for (int i = 0; i < 1000; i++) {
211 queue.TryDequeue(out res);
222 queue.TryDequeue(out res);
212 Assert.AreEqual(i, res);
223 Assert.AreEqual(i, res);
213 }
224 }
214
225
215 int writers = 0;
226 int writers = 0;
216 int readers = 0;
227 int readers = 0;
217 var stop = new ManualResetEvent(false);
228 var stop = new ManualResetEvent(false);
218 int total = 0;
229 int total = 0;
219
230
220 int itemsPerWriter = 10000;
231 const int itemsPerWriter = 10000;
221 int writersCount = 10;
232 const int writersCount = 10;
222
233
223 for (int i = 0; i < writersCount; i++) {
234 for (int i = 0; i < writersCount; i++) {
224 Interlocked.Increment(ref writers);
235 Interlocked.Increment(ref writers);
225 var wn = i;
226 AsyncPool
236 AsyncPool
227 .InvokeNewThread(() => {
237 .InvokeNewThread(() => {
228 for (int ii = 0; ii < itemsPerWriter; ii++) {
238 for (int ii = 0; ii < itemsPerWriter; ii++) {
229 queue.Enqueue(1);
239 queue.Enqueue(1);
230 }
240 }
231 return 1;
241 return 1;
232 })
242 })
233 .Anyway(() => Interlocked.Decrement(ref writers));
243 .Anyway(() => Interlocked.Decrement(ref writers));
234 }
244 }
235
245
236 for (int i = 0; i < 10; i++) {
246 for (int i = 0; i < 10; i++) {
237 Interlocked.Increment(ref readers);
247 Interlocked.Increment(ref readers);
238 var wn = i;
239 AsyncPool
248 AsyncPool
240 .InvokeNewThread(() => {
249 .InvokeNewThread(() => {
241 int t;
250 int t;
242 do {
251 do {
243 while (queue.TryDequeue(out t))
252 while (queue.TryDequeue(out t))
244 Interlocked.Add(ref total, t);
253 Interlocked.Add(ref total, t);
245 } while (writers > 0);
254 } while (writers > 0);
246 return 1;
255 return 1;
247 })
256 })
248 .Anyway(() => {
257 .Anyway(() => {
249 Interlocked.Decrement(ref readers);
258 Interlocked.Decrement(ref readers);
250 if (readers == 0)
259 if (readers == 0)
251 stop.Set();
260 stop.Set();
252 });
261 });
253 }
262 }
254
263
255 stop.WaitOne();
264 stop.WaitOne();
256
265
257 Assert.AreEqual(itemsPerWriter * writersCount, total);
266 Assert.AreEqual(itemsPerWriter * writersCount, total);
258 }
267 }
259
268
260 [TestMethod]
269 [TestMethod]
261 public void ParallelMapTest() {
270 public void ParallelMapTest() {
262
271
263 int count = 100000;
272 const int count = 100000;
264
273
265 double[] args = new double[count];
274 var args = new double[count];
266 var rand = new Random();
275 var rand = new Random();
267
276
268 for (int i = 0; i < count; i++)
277 for (int i = 0; i < count; i++)
269 args[i] = rand.NextDouble();
278 args[i] = rand.NextDouble();
270
279
271 var t = Environment.TickCount;
280 var t = Environment.TickCount;
272 var res = args.ParallelMap(x => Math.Sin(x*x), 4).Join();
281 var res = args.ParallelMap(x => Math.Sin(x*x), 4).Join();
273
282
274 Console.WriteLine("Map complete in {0} ms", Environment.TickCount - t);
283 Console.WriteLine("Map complete in {0} ms", Environment.TickCount - t);
275
284
276 t = Environment.TickCount;
285 t = Environment.TickCount;
277 for (int i = 0; i < count; i++)
286 for (int i = 0; i < count; i++)
278 Assert.AreEqual(Math.Sin(args[i] * args[i]), res[i]);
287 Assert.AreEqual(Math.Sin(args[i] * args[i]), res[i]);
279 Console.WriteLine("Verified in {0} ms", Environment.TickCount - t);
288 Console.WriteLine("Verified in {0} ms", Environment.TickCount - t);
280 }
289 }
281
290
282 [TestMethod]
291 [TestMethod]
283 public void ChainedMapTest() {
292 public void ChainedMapTest() {
284
293
285 using (var pool = new WorkerPool(0,100,100)) {
294 using (var pool = new WorkerPool(0,100,100)) {
286 int count = 10000;
295 const int count = 10000;
287
296
288 double[] args = new double[count];
297 var args = new double[count];
289 var rand = new Random();
298 var rand = new Random();
290
299
291 for (int i = 0; i < count; i++)
300 for (int i = 0; i < count; i++)
292 args[i] = rand.NextDouble();
301 args[i] = rand.NextDouble();
293
302
294 var t = Environment.TickCount;
303 var t = Environment.TickCount;
295 var res = args
304 var res = args
296 .ChainedMap(
305 .ChainedMap(
306 // Analysis disable once AccessToDisposedClosure
297 x => pool.Invoke(
307 x => pool.Invoke(
298 () => Math.Sin(x * x)
308 () => Math.Sin(x * x)
299 ),
309 ),
300 4
310 4
301 )
311 )
302 .Join();
312 .Join();
303
313
304 Console.WriteLine("Map complete in {0} ms", Environment.TickCount - t);
314 Console.WriteLine("Map complete in {0} ms", Environment.TickCount - t);
305
315
306 t = Environment.TickCount;
316 t = Environment.TickCount;
307 for (int i = 0; i < count; i++)
317 for (int i = 0; i < count; i++)
308 Assert.AreEqual(Math.Sin(args[i] * args[i]), res[i]);
318 Assert.AreEqual(Math.Sin(args[i] * args[i]), res[i]);
309 Console.WriteLine("Verified in {0} ms", Environment.TickCount - t);
319 Console.WriteLine("Verified in {0} ms", Environment.TickCount - t);
310 Console.WriteLine("Max workers: {0}", pool.MaxRunningThreads);
320 Console.WriteLine("Max workers: {0}", pool.MaxRunningThreads);
311 }
321 }
312 }
322 }
313
323
314 [TestMethod]
324 [TestMethod]
315 public void ParallelForEachTest() {
325 public void ParallelForEachTest() {
316
326
317 int count = 100000;
327 const int count = 100000;
318
328
319 int[] args = new int[count];
329 var args = new int[count];
320 var rand = new Random();
330 var rand = new Random();
321
331
322 for (int i = 0; i < count; i++)
332 for (int i = 0; i < count; i++)
323 args[i] = (int)(rand.NextDouble() * 100);
333 args[i] = (int)(rand.NextDouble() * 100);
324
334
325 int result = 0;
335 int result = 0;
326
336
327 var t = Environment.TickCount;
337 var t = Environment.TickCount;
328 args.ParallelForEach(x => Interlocked.Add(ref result, x), 4).Join();
338 args.ParallelForEach(x => Interlocked.Add(ref result, x), 4).Join();
329
339
330 Console.WriteLine("Iteration complete in {0} ms, result: {1}", Environment.TickCount - t, result);
340 Console.WriteLine("Iteration complete in {0} ms, result: {1}", Environment.TickCount - t, result);
331
341
332 int result2 = 0;
342 int result2 = 0;
333
343
334 t = Environment.TickCount;
344 t = Environment.TickCount;
335 for (int i = 0; i < count; i++)
345 for (int i = 0; i < count; i++)
336 result2 += args[i];
346 result2 += args[i];
337 Assert.AreEqual(result2, result);
347 Assert.AreEqual(result2, result);
338 Console.WriteLine("Verified in {0} ms", Environment.TickCount - t);
348 Console.WriteLine("Verified in {0} ms", Environment.TickCount - t);
339 }
349 }
340
350
341 [TestMethod]
351 [TestMethod]
342 public void ComplexCase1Test() {
352 public void ComplexCase1Test() {
343 var flags = new bool[3];
353 var flags = new bool[3];
344
354
345 // op1 (aync 200ms) => op2 (async 200ms) => op3 (sync map)
355 // op1 (aync 200ms) => op2 (async 200ms) => op3 (sync map)
346
356
347 var p = PromiseHelper
357 var step1 = PromiseHelper
348 .Sleep(200, "Alan")
358 .Sleep(200, "Alan")
349 .Cancelled(() => flags[0] = true)
359 .Cancelled(() => flags[0] = true);
360 var p = step1
350 .Chain(x =>
361 .Chain(x =>
351 PromiseHelper
362 PromiseHelper
352 .Sleep(200, "Hi, " + x)
363 .Sleep(200, "Hi, " + x)
353 .Then(y => y)
364 .Then(y => y)
354 .Cancelled(() => flags[1] = true)
365 .Cancelled(() => flags[1] = true)
355 )
366 )
356 .Cancelled(() => flags[2] = true);
367 .Cancelled(() => flags[2] = true);
357 Thread.Sleep(300);
368 step1.Join();
358 p.Cancel();
369 p.Cancel();
359 try {
370 try {
360 Assert.AreEqual(p.Join(), "Hi, Alan");
371 Assert.AreEqual(p.Join(), "Hi, Alan");
361 Assert.Fail("Shouldn't get here");
372 Assert.Fail("Shouldn't get here");
362 } catch (OperationCanceledException) {
373 } catch (OperationCanceledException) {
363 }
374 }
364
375
365 Assert.IsFalse(flags[0]);
376 Assert.IsFalse(flags[0]);
366 Assert.IsTrue(flags[1]);
377 Assert.IsTrue(flags[1]);
367 Assert.IsTrue(flags[2]);
378 Assert.IsTrue(flags[2]);
368 }
379 }
369
380
370 [TestMethod]
381 [TestMethod]
371 public void ChainedCancel1Test() {
382 public void ChainedCancel1Test() {
372 // при отмене сцепленной асинхронной операции все обещание должно
383 // при отмене сцепленной асинхронной операции все обещание должно
373 // завершаться ошибкой OperationCanceledException
384 // завершаться ошибкой OperationCanceledException
374 var p = PromiseHelper
385 var p = PromiseHelper
375 .Sleep(1, "Hi, HAL!")
386 .Sleep(1, "Hi, HAL!")
376 .Then(x => {
387 .Then(x => {
377 // запускаем две асинхронные операции
388 // запускаем две асинхронные операции
378 var result = PromiseHelper.Sleep(1000, "HEM ENABLED!!!");
389 var result = PromiseHelper.Sleep(1000, "HEM ENABLED!!!");
379 // вторая операция отменяет первую до завершения
390 // вторая операция отменяет первую до завершения
380 PromiseHelper
391 PromiseHelper
381 .Sleep(100, "HAL, STOP!")
392 .Sleep(100, "HAL, STOP!")
382 .Then(() => result.Cancel());
393 .Then(result.Cancel);
383 return result;
394 return result;
384 });
395 });
385 try {
396 try {
386 p.Join();
397 p.Join();
387 } catch (TargetInvocationException err) {
398 } catch (TargetInvocationException err) {
388 Assert.IsTrue(err.InnerException is OperationCanceledException);
399 Assert.IsTrue(err.InnerException is OperationCanceledException);
389 }
400 }
390 }
401 }
391
402
392 [TestMethod]
403 [TestMethod]
393 public void ChainedCancel2Test() {
404 public void ChainedCancel2Test() {
394 // при отмене цепочки обещаний, вложенные операции также должны отменяться
405 // при отмене цепочки обещаний, вложенные операции также должны отменяться
395 var pSurvive = new Promise<bool>();
406 var pSurvive = new Promise<bool>();
396 var hemStarted = new ManualResetEvent(false);
407 var hemStarted = new ManualResetEvent(false);
397 var p = PromiseHelper
408 var p = PromiseHelper
398 .Sleep(1, "Hi, HAL!")
409 .Sleep(1, "Hi, HAL!")
399 .Chain(x => {
410 .Chain(x => {
400 hemStarted.Set();
411 hemStarted.Set();
401 // запускаем две асинхронные операции
412 // запускаем две асинхронные операции
402 var result = PromiseHelper
413 var result = PromiseHelper
403 .Sleep(10000, "HEM ENABLED!!!")
414 .Sleep(10000, "HEM ENABLED!!!")
404 .Then(s => pSurvive.Resolve(false));
415 .Then(s => pSurvive.Resolve(false));
405
416
406 result
417 result
407 .Cancelled(() => pSurvive.Resolve(true));
418 .Cancelled(() => pSurvive.Resolve(true));
408
419
409 return result;
420 return result;
410 });
421 });
411
422
412 hemStarted.WaitOne();
423 hemStarted.WaitOne();
413 p.Cancel();
424 p.Cancel();
414
425
415 try {
426 try {
416 p.Join();
427 p.Join();
417 } catch (OperationCanceledException) {
428 } catch (OperationCanceledException) {
418 Assert.IsTrue(pSurvive.Join());
429 Assert.IsTrue(pSurvive.Join());
419 }
430 }
420 }
431 }
421 }
432 }
422 }
433 }
423
434
@@ -1,17 +1,13
1 using Implab.Parallels;
1 using Implab.Parallels;
2 using System;
3 using System.Collections.Generic;
4 using System.Linq;
5 using System.Text;
6 using System.Threading;
2 using System.Threading;
7
3
8 namespace Implab.Test {
4 namespace Implab.Test {
9 class PromiseHelper {
5 static class PromiseHelper {
10 public static IPromise<T> Sleep<T>(int timeout, T retVal) {
6 public static IPromise<T> Sleep<T>(int timeout, T retVal) {
11 return AsyncPool.Invoke(() => {
7 return AsyncPool.Invoke(() => {
12 Thread.Sleep(timeout);
8 Thread.Sleep(timeout);
13 return retVal;
9 return retVal;
14 });
10 });
15 }
11 }
16 }
12 }
17 }
13 }
@@ -1,35 +1,34
1 using System.Reflection;
1 using System.Reflection;
2 using System.Runtime.CompilerServices;
2 using System.Runtime.CompilerServices;
3 using System.Runtime.InteropServices;
3 using System.Runtime.InteropServices;
4
4
5 // General Information about an assembly is controlled through the following
5 // General Information about an assembly is controlled through the following
6 // set of attributes. Change these attribute values to modify the information
6 // set of attributes. Change these attribute values to modify the information
7 // associated with an assembly.
7 // associated with an assembly.
8 [assembly: AssemblyTitle("Implab.Test")]
8 [assembly: AssemblyTitle("Implab.Test")]
9 [assembly: AssemblyDescription("")]
9 [assembly: AssemblyDescription("")]
10 [assembly: AssemblyConfiguration("")]
10 [assembly: AssemblyConfiguration("")]
11 [assembly: AssemblyCompany("")]
11 [assembly: AssemblyCompany("")]
12 [assembly: AssemblyProduct("Implab.Test")]
12 [assembly: AssemblyProduct("Implab.Test")]
13 [assembly: AssemblyCopyright("Copyright © 2013")]
13 [assembly: AssemblyCopyright("Copyright © 2013")]
14 [assembly: AssemblyTrademark("")]
14 [assembly: AssemblyTrademark("")]
15 [assembly: AssemblyCulture("")]
15 [assembly: AssemblyCulture("")]
16
16
17 // Setting ComVisible to false makes the types in this assembly not visible
17 // Setting ComVisible to false makes the types in this assembly not visible
18 // to COM components. If you need to access a type in this assembly from
18 // to COM components. If you need to access a type in this assembly from
19 // COM, set the ComVisible attribute to true on that type.
19 // COM, set the ComVisible attribute to true on that type.
20 [assembly: ComVisible(false)]
20 [assembly: ComVisible(false)]
21
21
22 // The following GUID is for the ID of the typelib if this project is exposed to COM
22 // The following GUID is for the ID of the typelib if this project is exposed to COM
23 [assembly: Guid("bfcae720-21eb-4411-b70a-6eeab99071de")]
23 [assembly: Guid("bfcae720-21eb-4411-b70a-6eeab99071de")]
24
24
25 // Version information for an assembly consists of the following four values:
25 // Version information for an assembly consists of the following four values:
26 //
26 //
27 // Major Version
27 // Major Version
28 // Minor Version
28 // Minor Version
29 // Build Number
29 // Build Number
30 // Revision
30 // Revision
31 //
31 //
32 // You can specify all the values or you can default the Build and Revision Numbers
32 // You can specify all the values or you can default the Build and Revision Numbers
33 // by using the '*' as shown below:
33 // by using the '*' as shown below:
34 [assembly: AssemblyVersion("1.0.0.0")]
34 [assembly: AssemblyVersion("0.0.*")]
35 [assembly: AssemblyFileVersion("1.0.0.0")]
General Comments 0
You need to be logged in to leave comments. Login now