-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGetOrderTests.cs
70 lines (55 loc) · 1.86 KB
/
GetOrderTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using Application.Shared.Exceptions;
using Application.UseCases.GetOrder;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Test.IntegrationTests;
using Test.IntergationTests.TextFixtures;
using Xunit;
namespace Test.IntergationTests.OrderTests
{
[Collection("Test Data collection")]
public class GetOrderTests : TestsBase
{
private TestClientFixture _testClientFixture;
public GetOrderTests(TestClientFixture testClientFixture)
{
_testClientFixture = testClientFixture;
}
[Fact]
public void t()
{
Assert.Equal(1, 1);
}
[Theory]
[ClassData(typeof(UnauthorizedOrderAccess))]
[ClassData(typeof(AuthorizedOrderAccess))]
public async Task OrderAuthorizationTests(int clientId, int orderId, bool expectedResult)
{
bool actualResult = true;
var response = await _testClientFixture.Client.GetAsync("v1/demo/orders/" + clientId + "/" + orderId);
var responseStatus = response.StatusCode;
if(responseStatus == System.Net.HttpStatusCode.Unauthorized)
actualResult = false;
Assert.Equal(expectedResult, actualResult);
}
}
public class UnauthorizedOrderAccess : IEnumerable<object[]>
{
public IEnumerator<object[]> GetEnumerator()
{
yield return new object[] { 7, 6564, false };
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
public class AuthorizedOrderAccess : IEnumerable<object[]>
{
public IEnumerator<object[]> GetEnumerator()
{
yield return new object[] { 1009, 6564, true };
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}