Skip to content

Commit 5e46d26

Browse files
committed
Add commandlet project + first test commandlet
1 parent 1e8635f commit 5e46d26

File tree

10 files changed

+404
-1
lines changed

10 files changed

+404
-1
lines changed

src/CLU/CLUCoreCLR.sln

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.23107.0
4+
VisualStudioVersion = 14.0.24720.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Commands.Common", "Commands.Common\Commands.Common.xproj", "{5F567ACA-595E-436D-83DB-A21E08F82DF6}"
77
EndProject
@@ -37,6 +37,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.CLU.Run", "Micros
3737
EndProject
3838
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.CLU", "Microsoft.CLU\Microsoft.CLU.xproj", "{D0A59671-088D-463B-B060-2ADAFFB9C3F6}"
3939
EndProject
40+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.CLU.Test", "Microsoft.CLU.Test\Microsoft.CLU.Test.xproj", "{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}"
41+
EndProject
4042
Global
4143
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4244
Debug|Any CPU = Debug|Any CPU
@@ -111,6 +113,10 @@ Global
111113
{D0A59671-088D-463B-B060-2ADAFFB9C3F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
112114
{D0A59671-088D-463B-B060-2ADAFFB9C3F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
113115
{D0A59671-088D-463B-B060-2ADAFFB9C3F6}.Release|Any CPU.Build.0 = Release|Any CPU
116+
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
117+
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
118+
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
119+
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Release|Any CPU.Build.0 = Release|Any CPU
114120
EndGlobalSection
115121
GlobalSection(SolutionProperties) = preSolution
116122
HideSolutionNode = FALSE
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
RtPackage: Microsoft.CLU.Commands
2+
RtEntry: Microsoft.CLU.CommandModel.CmdletCommandModel.Run
3+
RtAssembly: Microsoft.CLU.dll
4+
Modules: Microsoft.CLU.Test
5+
NounPrefix: AzureRm
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Name: Microsoft.CLU.Test
2+
CommandAssemblies: Microsoft.CLU.Test.dll
3+
NounPrefix: Test
4+
NounFirst: true
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0"?>
2+
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
3+
<metadata minClientVersion="2.5">
4+
<id>Microsoft.CLU.Test</id>
5+
<title>Microsoft CLU CommandLine test command packge</title>
6+
<version>%PackageVersion%</version>
7+
<authors>Microsoft</authors>
8+
<owners>azure-sdk, PowerShell, Microsoft</owners>
9+
<licenseUrl>http://aka.ms/windowsazureapache2</licenseUrl>
10+
<projectUrl>https://github.com/Azure/azure-powershell</projectUrl>
11+
<iconUrl>http://go.microsoft.com/fwlink/?LinkID=288890</iconUrl>
12+
<requireLicenseAcceptance>true</requireLicenseAcceptance>
13+
<summary>Execution package for Microsoft CLU packages</summary>
14+
<description>
15+
Cross-Platform command package for clurun
16+
17+
Supported Library Platforms:
18+
- .NET Framework 5.0
19+
</description>
20+
<copyright>Copyright © Microsoft Corporation</copyright>
21+
<tags>Private test</tags>
22+
<references>
23+
<group targetFramework="dnxcore50">
24+
%ReferenceFiles% </group>
25+
</references>
26+
<dependencies/>
27+
</metadata>
28+
<files>
29+
%SourceFiles%%ContentFiles% </files>
30+
</package>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0.24711" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.24711</VisualStudioVersion>
5+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
6+
</PropertyGroup>
7+
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
8+
<PropertyGroup Label="Globals">
9+
<ProjectGuid>91422b55-28a5-48de-bca0-30c3e30ffb1c</ProjectGuid>
10+
<RootNamespace>Microsoft.Azure.Commands.Resources.Test</RootNamespace>
11+
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
12+
<OutputPath Condition="'$(OutputPath)'=='' ">..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
13+
</PropertyGroup>
14+
<PropertyGroup>
15+
<SchemaVersion>2.0</SchemaVersion>
16+
</PropertyGroup>
17+
<ItemGroup>
18+
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
19+
</ItemGroup>
20+
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
21+
</Project>
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
6+
using System.Management.Automation;
7+
8+
namespace Microsoft.Azure.Commands.Resources.Test
9+
{
10+
11+
public class TestRecord
12+
{
13+
public const string DefaultName = "This is the name...";
14+
public const string DefaultValue = "This is the value!";
15+
public const string DefaultSomethingElseValue = "This is the SomethingElse value.";
16+
17+
public TestRecord()
18+
{
19+
Name = DefaultName;
20+
Value = DefaultValue;
21+
SomethingElse = DefaultSomethingElseValue;
22+
}
23+
24+
[Parameter(Mandatory = false)]
25+
public string Name { get; set; }
26+
27+
[Parameter(Mandatory = false)]
28+
public string Value { get; set; }
29+
30+
[Parameter(Mandatory = false)]
31+
public string SomethingElse { get; set; }
32+
}
33+
34+
[Cmdlet(VerbsCommon.New, "TestRecord"), OutputType(typeof(TestRecord))]
35+
public class NewTestRecord : PSCmdlet
36+
{
37+
protected override void ProcessRecord()
38+
{
39+
base.ProcessRecord();
40+
41+
WriteObject(new TestRecord());
42+
}
43+
}
44+
45+
[Cmdlet(VerbsCommon.Show, "TestRecord")]
46+
public class ShowTestRecord : PSCmdlet
47+
{
48+
49+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true)]
50+
[Alias("Name")]
51+
public string RecordName { get; set; }
52+
53+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true)]
54+
[Alias("Val")]
55+
public string Value { get; set; }
56+
57+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true)]
58+
public string SomethingElse { get; set; }
59+
60+
protected override void ProcessRecord()
61+
{
62+
base.ProcessRecord();
63+
ErrorRecord errorRecord = null;
64+
if (!String.Equals(TestRecord.DefaultValue, Value))
65+
{
66+
errorRecord = new ErrorRecord(
67+
new InvalidOperationException($"Value mismatch - got {Value}, expected {TestRecord.DefaultValue}"),
68+
"TestAssert",
69+
ErrorCategory.InvalidOperation,
70+
this);
71+
this.WriteError(errorRecord);
72+
}
73+
else if (!String.Equals(TestRecord.DefaultName, RecordName))
74+
{
75+
errorRecord = new ErrorRecord(
76+
new InvalidOperationException($"Value mismatch - got {RecordName}, expected {TestRecord.DefaultName}"),
77+
"TestAssert",
78+
ErrorCategory.InvalidOperation,
79+
this);
80+
this.WriteError(errorRecord);
81+
}
82+
else if (!String.Equals(TestRecord.DefaultSomethingElseValue, SomethingElse))
83+
{
84+
errorRecord = new ErrorRecord(
85+
new InvalidOperationException($"Value mismatch - got {SomethingElse}, expected {TestRecord.DefaultSomethingElseValue}"),
86+
"TestAssert",
87+
ErrorCategory.InvalidOperation,
88+
this);
89+
this.WriteError(errorRecord);
90+
}
91+
92+
if (errorRecord != null)
93+
{
94+
ThrowTerminatingError(errorRecord);
95+
}
96+
WriteObject(new TestRecord() { Name = $"Matched {RecordName}", Value = $"Matched {Value}", SomethingElse = $"Matched {SomethingElse}" });
97+
}
98+
}
99+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System.Reflection;
16+
using System.Runtime.InteropServices;
17+
18+
// General Information about an assembly is controlled through the following
19+
// set of attributes. Change these attribute values to modify the information
20+
// associated with an assembly.
21+
[assembly: AssemblyTitle("Microsoft.CLU.Test")]
22+
[assembly: AssemblyDescription("")]
23+
[assembly: AssemblyConfiguration("")]
24+
[assembly: AssemblyCompany("")]
25+
[assembly: AssemblyProduct("Microsoft.CLU.Test")]
26+
[assembly: AssemblyCopyright("Copyright © Microsoft")]
27+
[assembly: AssemblyTrademark("")]
28+
[assembly: AssemblyCulture("")]
29+
30+
[assembly: ComVisible(false)]
31+
32+
[assembly: Guid("CE4E634B-0219-4357-9EA5-AFA92667A9D3")]
33+
34+
[assembly: AssemblyVersion("1.0.0")]
35+
[assembly: AssemblyFileVersion("1.0.0")]

src/CLU/Microsoft.CLU.Test/Properties/Resources.Designer.cs

Lines changed: 63 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)