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 ;
16
+ using Microsoft . Azure . Commands . Automation . Cmdlet ;
17
+ using Microsoft . Azure . Commands . Automation . Common ;
18
+ using Microsoft . Azure . Commands . Automation . Model ;
19
+ using Microsoft . VisualStudio . TestTools . UnitTesting ;
20
+ using Microsoft . WindowsAzure . Commands . Common . Test . Mocks ;
21
+ using Microsoft . WindowsAzure . Commands . ScenarioTest ;
22
+ using Microsoft . WindowsAzure . Commands . Test . Utilities . Common ;
23
+ using Microsoft . WindowsAzure . Commands . Utilities . Common ;
24
+ using Moq ;
25
+ using System . Collections . Generic ;
26
+ using Xunit ;
27
+
28
+ namespace Microsoft . Azure . Commands . ResourceManager . Automation . Test . UnitTests
29
+ {
30
+ [ TestClass ]
31
+ public class GetAzureAutomationDscCompilationJobTest : RMTestBase
32
+ {
33
+ private Mock < IAutomationClient > mockAutomationClient ;
34
+
35
+ private MockCommandRuntime mockCommandRuntime ;
36
+
37
+ private GetAzureAutomationDscCompilationJob cmdlet ;
38
+
39
+
40
+ public GetAzureAutomationDscCompilationJobTest ( )
41
+ {
42
+ this . mockAutomationClient = new Mock < IAutomationClient > ( ) ;
43
+ this . mockCommandRuntime = new MockCommandRuntime ( ) ;
44
+ this . cmdlet = new GetAzureAutomationDscCompilationJob
45
+ {
46
+ AutomationClient = this . mockAutomationClient . Object ,
47
+ CommandRuntime = this . mockCommandRuntime
48
+ } ;
49
+ }
50
+
51
+ [ Fact ]
52
+ [ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
53
+
54
+ public void GetAzureAutomationGetCompilationJobByIdSuccessfull ( )
55
+ {
56
+ // Setup
57
+ string resourceGroupName = "resourceGroup" ;
58
+ string accountName = "account" ;
59
+ Guid id = Guid . NewGuid ( ) ;
60
+
61
+ this . mockAutomationClient . Setup ( f => f . GetCompilationJob ( resourceGroupName , accountName , id ) ) . Returns ( ( string a , string b , Guid c ) => new CompilationJob ( ) ) ;
62
+
63
+ // Test
64
+ this . cmdlet . ResourceGroupName = resourceGroupName ;
65
+ this . cmdlet . AutomationAccountName = accountName ;
66
+ this . cmdlet . Id = id ;
67
+ this . cmdlet . ExecuteCmdlet ( ) ;
68
+
69
+ // Assert
70
+ this . mockAutomationClient . Verify ( f => f . GetCompilationJob ( resourceGroupName , accountName , id ) , Times . Once ( ) ) ;
71
+ }
72
+
73
+ [ Fact ]
74
+ [ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
75
+
76
+ public void GetAzureAutomationCompilationJobsByConfigurationNameSuccessfull ( )
77
+ {
78
+ // Setup
79
+ string resourceGroupName = "resourceGroup" ;
80
+ string accountName = "account" ;
81
+ string configurationName = "configuration" ;
82
+ string nextLink = string . Empty ;
83
+ DateTimeOffset startTime = DateTimeOffset . Now ;
84
+ DateTimeOffset endTime = DateTimeOffset . Now ;
85
+ string status = "Completed" ;
86
+
87
+ this . mockAutomationClient . Setup ( f => f . ListCompilationJobsByConfigurationName ( resourceGroupName , accountName , configurationName , startTime , endTime , status , ref nextLink ) ) ;
88
+
89
+ // Test
90
+ this . cmdlet . ResourceGroupName = resourceGroupName ;
91
+ this . cmdlet . AutomationAccountName = accountName ;
92
+ this . cmdlet . ConfigurationName = configurationName ;
93
+ this . cmdlet . StartTime = startTime ;
94
+ this . cmdlet . EndTime = endTime ;
95
+ this . cmdlet . Status = status ;
96
+ this . cmdlet . ExecuteCmdlet ( ) ;
97
+
98
+ // Assert
99
+ this . mockAutomationClient . Verify ( f => f . ListCompilationJobsByConfigurationName ( resourceGroupName , accountName , configurationName , startTime , endTime , status , ref nextLink ) , Times . Once ( ) ) ;
100
+ }
101
+
102
+ [ Fact ]
103
+ [ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
104
+
105
+ public void GetAzureAutomationListCompilationJobs ( )
106
+ {
107
+ // Setup
108
+ string resourceGroupName = "resourceGroup" ;
109
+ string accountName = "account" ;
110
+ string nextLink = string . Empty ;
111
+ DateTimeOffset startTime = DateTimeOffset . Now ;
112
+ DateTimeOffset endTime = DateTimeOffset . Now ;
113
+ string status = "Completed" ;
114
+
115
+ this . mockAutomationClient . Setup ( f => f . ListCompilationJobs ( resourceGroupName , accountName , startTime , endTime , status , ref nextLink ) ) ;
116
+
117
+ // Test
118
+ this . cmdlet . ResourceGroupName = resourceGroupName ;
119
+ this . cmdlet . AutomationAccountName = accountName ;
120
+ this . cmdlet . StartTime = startTime ;
121
+ this . cmdlet . EndTime = endTime ;
122
+ this . cmdlet . Status = status ;
123
+ this . cmdlet . ExecuteCmdlet ( ) ;
124
+
125
+ // Assert
126
+ this . mockAutomationClient . Verify ( f => f . ListCompilationJobs ( resourceGroupName , accountName , startTime , endTime , status , ref nextLink ) , Times . Once ( ) ) ;
127
+ }
128
+ }
129
+ }
0 commit comments