Skip to content

Commit 870bd08

Browse files
Stub rowVersion in tests
1 parent 0516a6a commit 870bd08

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/Harri.SchoolDemoAPI.BlazorWASM/Components/EditStudentForm.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@
135135
Name = Student.Name,
136136
GPA = Student.GPA
137137
};
138-
var response = await _studentClient.UpdateStudent(StudentId!.Value, existingStudent);
138+
var response = await _studentClient.UpdateStudent(StudentId!.Value, existingStudent, null);
139139

140-
if (response is null or false)
140+
if (response is false)
141141
{
142142
DisableSubmit = false;
143143
ShowError = true;

src/Tests/Harri.SchoolDemoAPI.BlazorWASM.Tests.Unit/BunitTests/EditStudentFormTests.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ namespace Harri.SchoolDemoAPI.BlazorWASM.Tests.Unit.BunitTests
1414
/// These tests are written entirely in C#.
1515
/// Learn more at https://bunit.dev/docs/getting-started/writing-tests.html#creating-basic-tests-in-cs-files
1616
/// </summary>
17+
18+
//TODO update tests for rowVersion
19+
1720
[TestFixture]
1821
public class EditStudentFormTests : BunitTestContext
1922
{
@@ -197,8 +200,8 @@ public async Task EditStudent_ForExistingStudent_SubmitsSuccessfully()
197200
{
198201
// Arrange
199202
var mockExistingStudent = SetUpMockExistingStudent();
200-
_mockStudentApiClient.Setup(client => client.UpdateStudent(It.IsAny<int>(), It.IsAny<UpdateStudentDto>()))
201-
.Returns(Task.FromResult((bool?)true));
203+
_mockStudentApiClient.Setup(client => client.UpdateStudent(It.IsAny<int>(), It.IsAny<UpdateStudentDto>(), null))
204+
.Returns(Task.FromResult(true));
202205

203206
var editStudentForm = RenderComponent<EditStudentForm>(parameters => parameters.Add(s => s.StudentId, 123));
204207

@@ -218,18 +221,17 @@ public async Task EditStudent_ForExistingStudent_SubmitsSuccessfully()
218221
_mockStudentApiClient.Verify(
219222
x => x.UpdateStudent(123, It.Is<UpdateStudentDto>(
220223
dto => dto.Name == updatedName &&
221-
dto.GPA == mockExistingStudent.GPA)
224+
dto.GPA == mockExistingStudent.GPA), null
222225
), Times.Once);
223226
}
224227

225228
[TestCase(false)]
226-
[TestCase(null)]
227-
public async Task EditStudent_ForExistingStudent_ShowsErrorOnFailToUpdate(bool? updateStudentResponse)
229+
public async Task EditStudent_ForExistingStudent_ShowsErrorOnFailToUpdate(bool updateStudentResponse)
228230
{
229231
// Arrange
230232
var mockExistingStudent = SetUpMockExistingStudent();
231233

232-
_mockStudentApiClient.Setup(client => client.UpdateStudent(It.IsAny<int>(), It.IsAny<UpdateStudentDto>()))
234+
_mockStudentApiClient.Setup(client => client.UpdateStudent(It.IsAny<int>(), It.IsAny<UpdateStudentDto>(), null))
233235
.Returns(Task.FromResult(updateStudentResponse));
234236

235237
var editStudentForm = RenderComponent<EditStudentForm>(parameters => parameters.Add(s => s.StudentId, 123));
@@ -251,7 +253,7 @@ public async Task EditStudent_ForExistingStudent_ShowsErrorOnFailToUpdate(bool?
251253
_mockStudentApiClient.Verify(
252254
x => x.UpdateStudent(123, It.Is<UpdateStudentDto>(
253255
dto => dto.Name == updatedName &&
254-
dto.GPA == mockExistingStudent.GPA)
256+
dto.GPA == mockExistingStudent.GPA), null
255257
), Times.Once);
256258

257259
var errorAlert = editStudentForm.Find(ErrorAlertSelector);
@@ -280,7 +282,7 @@ public void EditStudent_ForExistingStudent_DoesNotSubmitWhenNoChangesMade()
280282

281283
// Assert
282284
button.IsDisabled().Should().BeTrue();
283-
_mockStudentApiClient.Verify(x => x.UpdateStudent(It.IsAny<int>(), It.IsAny<UpdateStudentDto>()), Times.Never);
285+
_mockStudentApiClient.Verify(x => x.UpdateStudent(It.IsAny<int>(), It.IsAny<UpdateStudentDto>(), null), Times.Never);
284286
}
285287

286288
[Test]

0 commit comments

Comments
 (0)