Skip to content

Commit dc51793

Browse files
committed
fixed and added unit tests for jobs
1 parent fa06234 commit dc51793

File tree

1 file changed

+53
-8
lines changed

1 file changed

+53
-8
lines changed

src/ServiceManagement/Automation/Commands.Automation.Test/UnitTests/GetAzureAutomationJobTest.cs

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ public void GetAzureAutomationJobByRunbookNameSuccessfull()
5252
string accountName = "automation";
5353
string runbookName = "runbook";
5454

55-
this.mockAutomationClient.Setup(f => f.ListJobsByRunbookName(accountName, runbookName, null, null));
55+
this.mockAutomationClient.Setup(f => f.ListJobsByRunbookName(accountName, runbookName, null, null, null));
5656

5757
// Test
5858
this.cmdlet.AutomationAccountName = accountName;
5959
this.cmdlet.RunbookName = runbookName;
6060
this.cmdlet.ExecuteCmdlet();
6161

6262
// Assert
63-
this.mockAutomationClient.Verify(f => f.ListJobsByRunbookName(accountName, runbookName, null, null), Times.Once());
63+
this.mockAutomationClient.Verify(f => f.ListJobsByRunbookName(accountName, runbookName, null, null, null), Times.Once());
6464
}
6565

6666
public void GetAzureAutomationJobByRunbookNamAndStartTimeEndTimeeSuccessfull()
@@ -71,15 +71,36 @@ public void GetAzureAutomationJobByRunbookNamAndStartTimeEndTimeeSuccessfull()
7171
DateTime startTime = new DateTime(2014, 12, 30, 17, 0, 0, 0);
7272
DateTime endTime = new DateTime(2014, 12, 30, 18, 0, 0, 0);
7373

74-
this.mockAutomationClient.Setup(f => f.ListJobsByRunbookName(accountName, runbookName, startTime, endTime));
74+
this.mockAutomationClient.Setup(f => f.ListJobsByRunbookName(accountName, runbookName, startTime, endTime, null));
7575

7676
// Test
7777
this.cmdlet.AutomationAccountName = accountName;
7878
this.cmdlet.RunbookName = runbookName;
7979
this.cmdlet.ExecuteCmdlet();
8080

8181
// Assert
82-
this.mockAutomationClient.Verify(f => f.ListJobsByRunbookName(accountName, runbookName, startTime, endTime), Times.Once());
82+
this.mockAutomationClient.Verify(f => f.ListJobsByRunbookName(accountName, runbookName, startTime, endTime, null), Times.Once());
83+
}
84+
85+
public void GetAzureAutomationCompletedJobByRunbookNamAndStartTimeEndTimeeSuccessfull()
86+
{
87+
// Setup
88+
string accountName = "automation";
89+
string runbookName = "runbook";
90+
DateTime startTime = new DateTime(2014, 12, 30, 17, 0, 0, 0);
91+
DateTime endTime = new DateTime(2014, 12, 30, 18, 0, 0, 0);
92+
string status = "Completed";
93+
94+
this.mockAutomationClient.Setup(f => f.ListJobsByRunbookName(accountName, runbookName, startTime, endTime, status));
95+
96+
// Test
97+
this.cmdlet.AutomationAccountName = accountName;
98+
this.cmdlet.RunbookName = runbookName;
99+
this.cmdlet.Status = status;
100+
this.cmdlet.ExecuteCmdlet();
101+
102+
// Assert
103+
this.mockAutomationClient.Verify(f => f.ListJobsByRunbookName(accountName, runbookName, startTime, endTime, status), Times.Once());
83104
}
84105

85106
[TestMethod]
@@ -88,14 +109,14 @@ public void GetAzureAutomationAllJobsSuccessfull()
88109
// Setup
89110
string accountName = "automation";
90111

91-
this.mockAutomationClient.Setup(f => f.ListJobs(accountName, null, null));
112+
this.mockAutomationClient.Setup(f => f.ListJobs(accountName, null, null, null));
92113

93114
// Test
94115
this.cmdlet.AutomationAccountName = accountName;
95116
this.cmdlet.ExecuteCmdlet();
96117

97118
// Assert
98-
this.mockAutomationClient.Verify(f => f.ListJobs(accountName, null, null), Times.Once());
119+
this.mockAutomationClient.Verify(f => f.ListJobs(accountName, null, null, null), Times.Once());
99120
}
100121

101122
[TestMethod]
@@ -107,7 +128,7 @@ public void GetAzureAutomationAllJobsBetweenStartAndEndTimeSuccessfull()
107128
DateTime endTime = new DateTime(2014, 12, 30, 18, 0, 0, 0);
108129

109130
// look for jobs between 5pm to 6pm on 30th december 2014
110-
this.mockAutomationClient.Setup(f => f.ListJobs(accountName, startTime, endTime));
131+
this.mockAutomationClient.Setup(f => f.ListJobs(accountName, startTime, endTime, null));
111132

112133
// Test
113134
this.cmdlet.AutomationAccountName = accountName;
@@ -116,7 +137,30 @@ public void GetAzureAutomationAllJobsBetweenStartAndEndTimeSuccessfull()
116137
this.cmdlet.ExecuteCmdlet();
117138

118139
// Assert
119-
this.mockAutomationClient.Verify(f => f.ListJobs(accountName, startTime, endTime), Times.Once());
140+
this.mockAutomationClient.Verify(f => f.ListJobs(accountName, startTime, endTime, null), Times.Once());
141+
}
142+
143+
[TestMethod]
144+
public void GetAzureAutomationAllCompletedJobsBetweenStartAndEndTimeSuccessfull()
145+
{
146+
// Setup
147+
string accountName = "automation";
148+
DateTime startTime = new DateTime(2014, 12, 30, 17, 0, 0, 0);
149+
DateTime endTime = new DateTime(2014, 12, 30, 18, 0, 0, 0);
150+
string status = "Completed";
151+
152+
// look for jobs between 5pm to 6pm on 30th december 2014
153+
this.mockAutomationClient.Setup(f => f.ListJobs(accountName, startTime, endTime, status));
154+
155+
// Test
156+
this.cmdlet.AutomationAccountName = accountName;
157+
this.cmdlet.StartTime = startTime;
158+
this.cmdlet.EndTime = endTime;
159+
this.cmdlet.Status = status;
160+
this.cmdlet.ExecuteCmdlet();
161+
162+
// Assert
163+
this.mockAutomationClient.Verify(f => f.ListJobs(accountName, startTime, endTime, status), Times.Once());
120164
}
121165

122166
public void GetAzureAutomationJobByIdSuccessfull()
@@ -136,5 +180,6 @@ public void GetAzureAutomationJobByIdSuccessfull()
136180
// Assert
137181
this.mockAutomationClient.Verify(f => f.GetJob(accountName, jobId), Times.Once());
138182
}
183+
139184
}
140185
}

0 commit comments

Comments
 (0)