Browse Source

Rename PersonAppService to PeopleAppService

pull/96/head
Halil İbrahim Kalkan 9 years ago
parent
commit
4be2cd2d46
  1. 30
      test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/PersonAppService_Tests.cs
  2. 6
      test/Volo.Abp.TestApp.Tests/Volo/Abp/TestApp/Application/PersonAppService_Tests.cs
  3. 4
      test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/IPeopleAppService.cs
  4. 6
      test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/PeopleAppService.cs

30
test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/PersonAppService_Tests.cs

@ -34,8 +34,8 @@ namespace Volo.Abp.AspNetCore.Mvc
[Fact] [Fact]
public async Task GetAll_Test() public async Task GetAll_Test()
{ {
//Ideally should be [GET] /api/app/person OK! //Ideally should be [GET] /api/app/people OK!
var result = await GetResponseAsObjectAsync<ListResultDto<PersonDto>>("/api/app/person"); var result = await GetResponseAsObjectAsync<ListResultDto<PersonDto>>("/api/app/people");
result.Items.Count.ShouldBeGreaterThan(0); result.Items.Count.ShouldBeGreaterThan(0);
} }
@ -44,8 +44,8 @@ namespace Volo.Abp.AspNetCore.Mvc
{ {
var firstPerson = _personRepository.GetList().First(); var firstPerson = _personRepository.GetList().First();
//Ideally should be [GET] /api/app/person/{id} OK! //Ideally should be [GET] /api/app/people/{id} OK!
var result = await GetResponseAsObjectAsync<PersonDto>($"/api/app/person/{firstPerson.Id}"); var result = await GetResponseAsObjectAsync<PersonDto>($"/api/app/people/{firstPerson.Id}");
result.Name.ShouldBe(firstPerson.Name); result.Name.ShouldBe(firstPerson.Name);
} }
@ -54,8 +54,8 @@ namespace Volo.Abp.AspNetCore.Mvc
{ {
var firstPerson = _personRepository.GetList().First(); var firstPerson = _personRepository.GetList().First();
//Ideally should be [DELETE] /api/app/person/{id} OK! //Ideally should be [DELETE] /api/app/people/{id} OK!
await Client.DeleteAsync($"/api/app/person/{firstPerson.Id}"); await Client.DeleteAsync($"/api/app/people/{firstPerson.Id}");
(await _personRepository.FindAsync(firstPerson.Id)).ShouldBeNull(); (await _personRepository.FindAsync(firstPerson.Id)).ShouldBeNull();
} }
@ -67,9 +67,9 @@ namespace Volo.Abp.AspNetCore.Mvc
var postData = _jsonSerializer.Serialize(new PersonDto {Name = "John", Age = 33}); var postData = _jsonSerializer.Serialize(new PersonDto {Name = "John", Age = 33});
//Ideally should be [POST] /api/app/person OK! //Ideally should be [POST] /api/app/people OK!
var response = await Client.PostAsync( var response = await Client.PostAsync(
"/api/app/person", "/api/app/people",
new StringContent(postData, Encoding.UTF8, "application/json") new StringContent(postData, Encoding.UTF8, "application/json")
); );
@ -100,9 +100,9 @@ namespace Volo.Abp.AspNetCore.Mvc
//Act //Act
//Ideally should be [PUT] /api/app/person/{id} OK! //Ideally should be [PUT] /api/app/people/{id} OK!
var response = await Client.PutAsync( var response = await Client.PutAsync(
$"/api/app/person/{updateDto.Id}", $"/api/app/people/{updateDto.Id}",
new StringContent(putData, Encoding.UTF8, "application/json") new StringContent(putData, Encoding.UTF8, "application/json")
); );
@ -136,7 +136,7 @@ namespace Volo.Abp.AspNetCore.Mvc
//Ideally should be [POST] /api/people/{id}/phones //Ideally should be [POST] /api/people/{id}/phones
var response = await Client.PostAsync( var response = await Client.PostAsync(
$"/api/app/person/{personToAddNewPhone.Id}/Phone", $"/api/app/people/{personToAddNewPhone.Id}/Phone",
new StringContent(postData, Encoding.UTF8, "application/json") new StringContent(postData, Encoding.UTF8, "application/json")
); );
@ -159,8 +159,8 @@ namespace Volo.Abp.AspNetCore.Mvc
{ {
var douglas = _personRepository.GetList().First(p => p.Name == "Douglas"); var douglas = _personRepository.GetList().First(p => p.Name == "Douglas");
//Ideally should be [GET] /api/person/{id}/phones?type=office //Ideally should be [GET] /api/people/{id}/phones?type=office
var result = await GetResponseAsObjectAsync<ListResultDto<PhoneDto>>($"/api/app/person/{douglas.Id}/Phones"); var result = await GetResponseAsObjectAsync<ListResultDto<PhoneDto>>($"/api/app/people/{douglas.Id}/Phones");
result.Items.Count.ShouldBe(douglas.Phones.Count); result.Items.Count.ShouldBe(douglas.Phones.Count);
} }
@ -170,8 +170,8 @@ namespace Volo.Abp.AspNetCore.Mvc
var douglas = _personRepository.GetList().First(p => p.Name == "Douglas"); var douglas = _personRepository.GetList().First(p => p.Name == "Douglas");
var firstPhone = douglas.Phones.First(); var firstPhone = douglas.Phones.First();
//Ideally should be [DELETE] /api/app/person/{id}/phones/{phoneId} //Ideally should be [DELETE] /api/app/people/{id}/phones/{phoneId}
await Client.DeleteAsync($"/api/app/person/{douglas.Id}/Phone?phoneId=" + firstPhone.Id); await Client.DeleteAsync($"/api/app/people/{douglas.Id}/Phone?phoneId=" + firstPhone.Id);
douglas = _personRepository.GetList().First(p => p.Name == "Douglas"); douglas = _personRepository.GetList().First(p => p.Name == "Douglas");
douglas.Phones.Any(p => p.Id == firstPhone.Id).ShouldBeFalse(); douglas.Phones.Any(p => p.Id == firstPhone.Id).ShouldBeFalse();

6
test/Volo.Abp.TestApp.Tests/Volo/Abp/TestApp/Application/PersonAppService_Tests.cs

@ -8,17 +8,17 @@ namespace Volo.Abp.TestApp.Application
{ {
public class PersonAppService_Tests : TestAppTestBase public class PersonAppService_Tests : TestAppTestBase
{ {
private readonly IPersonAppService _personAppService; private readonly IPeopleAppService _peopleAppService;
public PersonAppService_Tests() public PersonAppService_Tests()
{ {
_personAppService = ServiceProvider.GetRequiredService<IPersonAppService>(); _peopleAppService = ServiceProvider.GetRequiredService<IPeopleAppService>();
} }
[Fact] [Fact]
public async Task GetAll() public async Task GetAll()
{ {
var people = await _personAppService.GetList(new PagedAndSortedResultRequestDto()); var people = await _peopleAppService.GetList(new PagedAndSortedResultRequestDto());
people.Items.Count.ShouldBeGreaterThan(0); people.Items.Count.ShouldBeGreaterThan(0);
} }
} }

4
test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/IPersonAppService.cs → test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/IPeopleAppService.cs

@ -5,12 +5,12 @@ using Volo.Abp.Application.Services;
namespace Volo.Abp.TestApp.Application namespace Volo.Abp.TestApp.Application
{ {
public interface IPersonAppService : IAsyncCrudAppService<PersonDto> public interface IPeopleAppService : IAsyncCrudAppService<PersonDto>
{ {
Task<ListResultDto<PhoneDto>> GetPhones(Guid id, GetPersonPhonesFilter filter); Task<ListResultDto<PhoneDto>> GetPhones(Guid id, GetPersonPhonesFilter filter);
Task<PhoneDto> AddPhone(Guid id, PhoneDto phoneDto); Task<PhoneDto> AddPhone(Guid id, PhoneDto phoneDto);
Task DeletePhone(Guid id, long phoneId); Task RemovePhone(Guid id, long phoneId);
} }
} }

6
test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/PersonAppService.cs → test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/PeopleAppService.cs

@ -9,9 +9,9 @@ using Volo.Abp.Application.Services;
namespace Volo.Abp.TestApp.Application namespace Volo.Abp.TestApp.Application
{ {
public class PersonAppService : AsyncCrudAppService<Person, PersonDto>, IPersonAppService public class PeopleAppService : AsyncCrudAppService<Person, PersonDto>, IPeopleAppService
{ {
public PersonAppService(IQueryableRepository<Person> repository) public PeopleAppService(IQueryableRepository<Person> repository)
: base(repository) : base(repository)
{ {
@ -38,7 +38,7 @@ namespace Volo.Abp.TestApp.Application
return ObjectMapper.Map<Phone, PhoneDto>(phone); return ObjectMapper.Map<Phone, PhoneDto>(phone);
} }
public async Task DeletePhone(Guid id, long phoneId) public async Task RemovePhone(Guid id, long phoneId)
{ {
var person = await GetEntityByIdAsync(id); var person = await GetEntityByIdAsync(id);
person.Phones.RemoveAll(p => p.Id == phoneId); person.Phones.RemoveAll(p => p.Id == phoneId);
Loading…
Cancel
Save