@@ -16,9 +16,9 @@ namespace TesteBackendEnContact.Api.IntegrationTests
16
16
public class CompanyTests : IClassFixture < TestFixture < Startup > >
17
17
{
18
18
private readonly HttpClient _client ;
19
- private readonly string _baseUrl = "/api/Company" ;
19
+ public static readonly string _baseUrl = "/api/Company" ;
20
20
21
- private readonly List < SaveCompanyResource > _companies = new List < SaveCompanyResource >
21
+ public static readonly List < SaveCompanyResource > _companies = new List < SaveCompanyResource >
22
22
{
23
23
new SaveCompanyResource
24
24
{
@@ -45,7 +45,7 @@ public CompanyTests(TestFixture<Startup> fixture)
45
45
_client = fixture . Client ;
46
46
}
47
47
48
- private async Task < HttpResponseMessage > CreateCompany ( Company company )
48
+ private async Task < HttpResponseMessage > CreateCompany ( SaveCompanyResource company )
49
49
{
50
50
return await _client . PostAsync ( _baseUrl , ContentHelper . GetStringContent ( company ) ) ;
51
51
}
@@ -67,48 +67,29 @@ public async Task TestGetCompanyById()
67
67
[ Fact ]
68
68
public async Task TestCreateCompany ( )
69
69
{
70
- var company = new Company
71
- {
72
- Name = "Teste" ,
73
- Cnpj = "12345678901234" ,
74
- Email = "aa"
75
- } ;
76
- var response = await _client . PostAsync ( _baseUrl , ContentHelper . GetStringContent ( company ) ) ;
70
+ var response = await _client . PostAsync ( _baseUrl , ContentHelper . GetStringContent ( _companies [ 0 ] ) ) ;
77
71
78
72
response . EnsureSuccessStatusCode ( ) ;
79
73
}
80
74
81
75
[ Fact ]
82
76
public async Task TestUpdateCompany ( )
83
77
{
84
- var company = new Company
85
- {
86
- Name = "Teste" ,
87
- Cnpj = "12345678901234" ,
88
- Email = "aa"
89
- } ;
90
- var createCompanyResponse = await CreateCompany ( company ) ;
78
+ var createCompanyResponse = await CreateCompany ( _companies [ 0 ] ) ;
91
79
92
- var companyCreated = JsonConvert . DeserializeObject < Company > ( createCompanyResponse . Content . ReadAsStringAsync ( ) . Result ) ;
80
+ var companyCreated = JsonConvert . DeserializeObject < CompanyResource > ( createCompanyResponse . Content . ReadAsStringAsync ( ) . Result ) ;
93
81
94
- var response = await _client . PutAsync ( $ "{ _baseUrl } /{ companyCreated . Id } ", ContentHelper . GetStringContent ( company ) ) ;
82
+ var response = await _client . PutAsync ( $ "{ _baseUrl } /{ companyCreated . Id } ", ContentHelper . GetStringContent ( _companies [ 0 ] ) ) ;
95
83
96
84
response . EnsureSuccessStatusCode ( ) ;
97
85
}
98
86
99
87
[ Fact ]
100
88
public async Task TestDeleteCompany ( )
101
89
{
102
- var company = new Company
103
- {
104
- Name = "Teste" ,
105
- Cnpj = "12345678901234" ,
106
- Email = "aa"
107
- } ;
108
-
109
- var createCompanyResponse = await CreateCompany ( company ) ;
90
+ var createCompanyResponse = await CreateCompany ( _companies [ 0 ] ) ;
110
91
111
- var companyCreated = JsonConvert . DeserializeObject < Company > ( createCompanyResponse . Content . ReadAsStringAsync ( ) . Result ) ;
92
+ var companyCreated = JsonConvert . DeserializeObject < CompanyResource > ( createCompanyResponse . Content . ReadAsStringAsync ( ) . Result ) ;
112
93
113
94
var response = await _client . DeleteAsync ( $ "{ _baseUrl } /{ companyCreated . Id } ") ;
114
95
0 commit comments