Skip to content

Commit bfefe46

Browse files
committed
feat: criação de testes unitários
1 parent 3f61e9d commit bfefe46

File tree

4 files changed

+72
-1
lines changed

4 files changed

+72
-1
lines changed

ApiBrasil.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ VisualStudioVersion = 25.0.1705.6
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiBrasil", "ApiBrasil\ApiBrasil.csproj", "{6D99C8A1-DF46-41D7-85BB-1187A9379FFB}"
77
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{C362D7F6-1DE9-4E36-B5C4-FE63F3ECA325}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
1517
{6D99C8A1-DF46-41D7-85BB-1187A9379FFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
1618
{6D99C8A1-DF46-41D7-85BB-1187A9379FFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
1719
{6D99C8A1-DF46-41D7-85BB-1187A9379FFB}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{C362D7F6-1DE9-4E36-B5C4-FE63F3ECA325}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{C362D7F6-1DE9-4E36-B5C4-FE63F3ECA325}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{C362D7F6-1DE9-4E36-B5C4-FE63F3ECA325}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{C362D7F6-1DE9-4E36-B5C4-FE63F3ECA325}.Release|Any CPU.Build.0 = Release|Any CPU
1824
EndGlobalSection
1925
GlobalSection(SolutionProperties) = preSolution
2026
HideSolutionNode = FALSE

ApiBrasil/ApiBrasil.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Company>Api Brasil</Company>
99
<Authors>Bruno Hashimoto</Authors>
1010
<Description>Nuget para integração com os serviços da Api Brasil.</Description>
11-
<Version>1.1.7</Version>
11+
<Version>1.1.8</Version>
1212
<iconUrl>https://apibrasil.com.br/frontend/img/logo.png</iconUrl>
1313
</PropertyGroup>
1414

Tests/GenericCallerTests.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using Xunit;
2+
using FluentAssertions;
3+
using ApiBrasil;
4+
using ApiBrasil.Domain;
5+
using Microsoft.Extensions.Options;
6+
using System.Threading.Tasks;
7+
8+
namespace Tests
9+
{
10+
public class GenericCallerTests
11+
{
12+
[Fact]
13+
public async Task Call_ShouldReturnContent()
14+
{
15+
// Arrange
16+
var type = "exampleType";
17+
var action = "exampleAction";
18+
var content = "exampleContent";
19+
var config = new ApiBrasilConfiguration
20+
{
21+
SecretKey = "exampleSecretKey",
22+
PublicToken = "examplePublicToken",
23+
DeviceToken = "exampleDeviceToken",
24+
Authorization = "exampleAuthorization"
25+
};
26+
27+
// Act
28+
var result = await GenericCaller.Call(type, action, content, config);
29+
30+
// Assert
31+
result.Should().NotBeNull();
32+
result.Should().BeOfType<string>();
33+
result.Should().NotBeEmpty();
34+
}
35+
}
36+
}

Tests/Tests.csproj

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net7.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
8+
<IsPackable>false</IsPackable>
9+
<IsTestProject>true</IsTestProject>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
14+
<PackageReference Include="xunit" Version="2.4.2" />
15+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
16+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
17+
<PrivateAssets>all</PrivateAssets>
18+
</PackageReference>
19+
<PackageReference Include="coverlet.collector" Version="3.2.0">
20+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
21+
<PrivateAssets>all</PrivateAssets>
22+
</PackageReference>
23+
<PackageReference Include="FluentAssertions" Version="6.11.0" />
24+
</ItemGroup>
25+
26+
<ItemGroup>
27+
<ProjectReference Include="..\ApiBrasil\ApiBrasil.csproj" />
28+
</ItemGroup>
29+
</Project>

0 commit comments

Comments
 (0)