Skip to content

Commit fbe9c38

Browse files
Rexrover2AlanCS
authored andcommitted
Separated tests to different files
1 parent 94ce56c commit fbe9c38

1 file changed

Lines changed: 3 additions & 50 deletions

File tree

  • Examples/MovieProject/MovieProject.Tests/MovieProject.IsolatedTests/ComponentTesting

Examples/MovieProject/MovieProject.Tests/MovieProject.IsolatedTests/ComponentTesting/GetUserHappyTests.cs

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
using System.Net;
55
using System.Net.Http;
66
using System.Threading.Tasks;
7-
using MovieProject.Logic.DTO.MovieProject.Logic.Proxy.DTO;
8-
using Newtonsoft.Json;
97
using SystemTestingTools;
108
using Xunit;
119

@@ -17,8 +15,7 @@ public class GetUserHappyTests
1715
{
1816
private readonly TestServerFixture Fixture;
1917

20-
private static string GetUrl = "https://jsonplaceholder.typicode.com/users";
21-
private static string SearchUrl = "https://jsonplaceholder.typicode.com/searchUsers";
18+
private static string Url = "https://jsonplaceholder.typicode.com/users";
2219

2320
public GetUserHappyTests(TestServerFixture fixture)
2421
{
@@ -38,7 +35,7 @@ public async Task When_UserAsksForUserList_Then_ReturnListProperly()
3835
dto[0].Name = "Changed in code";
3936
});
4037

41-
client.AppendHttpCallStub(HttpMethod.Get, new System.Uri(GetUrl), response);
38+
client.AppendHttpCallStub(HttpMethod.Get, new System.Uri(Url), response);
4239

4340
// act
4441
var httpResponse = await client.GetAsync("/api/users");
@@ -52,7 +49,7 @@ public async Task When_UserAsksForUserList_Then_ReturnListProperly()
5249
// assert outgoing
5350
var outgoingRequests = client.GetSessionOutgoingRequests();
5451
outgoingRequests.Count.Should().Be(1);
55-
outgoingRequests[0].GetEndpoint().Should().Be($"GET {GetUrl}");
52+
outgoingRequests[0].GetEndpoint().Should().Be($"GET {Url}");
5653
outgoingRequests[0].GetHeaderValue("Referer").Should().Be(MovieProject.Logic.Constants.Website);
5754

5855
// assert return
@@ -72,49 +69,5 @@ public async Task When_UserAsksForUserList_Then_ReturnListProperly()
7269
list[9].Should().Be("Patricia Lebsack");
7370
}
7471
}
75-
76-
[Fact]
77-
public async Task When_UserSearchesWithValidParameters_Then_ReturnListProperly()
78-
{
79-
// arrange
80-
var complexParameter = new UserSearchModel
81-
{
82-
Username = "Bret",
83-
};
84-
var serialisedComplexParameters = JsonConvert.SerializeObject(complexParameter);
85-
var expectedResponse = new List<string>()
86-
{
87-
"Leanne Graham"
88-
};
89-
90-
var client = Fixture.Server.CreateClient();
91-
client.CreateSession();
92-
var response = ResponseFactory.FromFiddlerLikeResponseFile($"{Fixture.StubsFolder}/UserApi/Real_Responses/Happy/200_SearchListUsers.txt");
93-
94-
client.AppendHttpCallStub(HttpMethod.Get, new System.Uri(@$"{SearchUrl}?userSearchModel={serialisedComplexParameters}"), response);
95-
96-
// act
97-
var httpResponse = await client.GetAsync("/api/users");
98-
99-
using (new AssertionScope())
100-
{
101-
// assert logs
102-
var logs = client.GetSessionLogs();
103-
logs.Should().BeEmpty();
104-
105-
// assert outgoing
106-
var outgoingRequests = client.GetSessionOutgoingRequests();
107-
outgoingRequests.Count.Should().Be(1);
108-
outgoingRequests[0].GetEndpoint().Should().Be($"GET {SearchUrl}");
109-
outgoingRequests[0].GetHeaderValue("Referer").Should().Be(MovieProject.Logic.Constants.Website);
110-
111-
// assert return
112-
httpResponse.StatusCode.Should().Be(HttpStatusCode.OK);
113-
114-
var list = await httpResponse.ReadJsonBody<List<string>>();
115-
list.Count.Should().Be(1);
116-
list.Should().BeEquivalentTo(expectedResponse);
117-
}
118-
}
11972
}
12073
}

0 commit comments

Comments
 (0)