Skip to content

Commit

Permalink
Fix #958 (#960)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbeaugrand authored Jul 22, 2022
1 parent 5229998 commit 2981b3d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,10 @@ public async Task ChangeAvatarPropertiesShouldChangeAvatar()
var deviceModel = Fixture.Create<DeviceModel>();
var content = new MultipartFormDataContent();

_ = MockHttpClient.When(HttpMethod.Get, $"/api/models/{deviceModel.ModelId}/properties")
_ = MockHttpClient.When(HttpMethod.Post, $"/api/models/{deviceModel.ModelId}/avatar")
.With(m =>
{
_ = m.Content.Should().BeAssignableTo<ObjectContent<MultipartFormDataContent>>();
var body = m.Content as ObjectContent<MultipartFormDataContent>;
_ = body.Value.Should().BeEquivalentTo(content);
_ = m.Content.Should().BeEquivalentTo(content);
return true;
})
.Respond(HttpStatusCode.Created);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,10 @@ public async Task ChangeAvatarPropertiesShouldChangeAvatar()
};
var content = new MultipartFormDataContent();

_ = MockHttpClient.When(HttpMethod.Get, $"/api/lorawan/models/{deviceModel.ModelId}/properties")
_ = MockHttpClient.When(HttpMethod.Post, $"/api/lorawan/models/{deviceModel.ModelId}/avatar")
.With(m =>
{
_ = m.Content.Should().BeAssignableTo<ObjectContent<MultipartFormDataContent>>();
var body = m.Content as ObjectContent<MultipartFormDataContent>;
_ = body.Value.Should().BeEquivalentTo(content);
_ = m.Content.Should().BeEquivalentTo(content);
return true;
})
.Respond(HttpStatusCode.Created);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ public Task<string> GetAvatarUrl(string deviceModelId)
return this.http.GetStringAsync($"api/models/{deviceModelId}/avatar");
}

public Task ChangeAvatar(string deviceModelId, MultipartFormDataContent avatar)
public async Task ChangeAvatar(string deviceModelId, MultipartFormDataContent avatar)
{
return this.http.PostAsJsonAsync($"api/models/{deviceModelId}/avatar", avatar);
var result = await this.http.PostAsync($"api/models/{deviceModelId}/avatar", avatar);

_ = result.EnsureSuccessStatusCode();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ public Task<string> GetAvatarUrl(string deviceModelId)
return this.http.GetStringAsync($"api/lorawan/models/{deviceModelId}/avatar");
}

public Task ChangeAvatar(string deviceModelId, MultipartFormDataContent avatar)
public async Task ChangeAvatar(string deviceModelId, MultipartFormDataContent avatar)
{
return this.http.PostAsJsonAsync($"api/lorawan/models/{deviceModelId}/avatar", avatar);
var result = await this.http.PostAsync($"api/lorawan/models/{deviceModelId}/avatar", avatar);

_ = result.EnsureSuccessStatusCode();
}
}
}

0 comments on commit 2981b3d

Please sign in to comment.