Skip to content

Commit

Permalink
Merge pull request #26 from alexfariakof/develop
Browse files Browse the repository at this point in the history
Hotfix/Erro DownloadContentAsync
  • Loading branch information
alexfariakof authored Jun 8, 2024
2 parents aadf1b5 + 29e94c4 commit ebbf905
Show file tree
Hide file tree
Showing 34 changed files with 188 additions and 421 deletions.
2 changes: 0 additions & 2 deletions .documents/ApexChart.txt

This file was deleted.

251 changes: 0 additions & 251 deletions .documents/MGLU3.SA.csv

This file was deleted.

Binary file removed .documents/PBL Corretora ABC (1).pdf
Binary file not shown.
48 changes: 0 additions & 48 deletions .documents/SSR_config.txt

This file was deleted.

19 changes: 8 additions & 11 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
name: Build and Test
on:
workflow_call:

push:
branches:
- main
- develop

pull_request:
types: [opened, synchronize, reopened]
types: [opened]
branches:
- main

permissions:
contents: read

jobs:
build_and_test_net:
name: Build and Test .Net App
Expand All @@ -37,13 +34,13 @@ jobs:
dotnet-version: 8.0.x

- name: Build and Restore App
run: dotnet build ./HomeBrokerSPA/HomeBrokerSPA.csproj --restore
run: dotnet build ./HomeBrokerSPA/HomeBroker.SPA.csproj --restore
continue-on-error: false

- name: Test .Net App
run: |
dotnet tool install -g dotnet-reportgenerator-globaltool
dotnet test ./HomeBrokerXUnit/HomeBrokerXUnit.csproj
dotnet test ./HomeBrokerXUnit/HomeBroker.XUnit.csproj
continue-on-error: false


Expand Down Expand Up @@ -76,8 +73,8 @@ jobs:
npm run test:coverage
continue-on-error: false

trigger_tests_sonarcloud:
needs: build_and_test_angular
name: Triggered Build and Test
uses: alexfariakof/Home_Broker_Chart/.github/workflows/test_analyse_in_Sonar_Cloud.yml@main
secrets: inherit
# trigger_tests_sonarcloud:
# needs: build_and_test_angular
# name: Triggered Build and Test
# uses: alexfariakof/app-home-broker-chart/.github/workflows/test_analyse_in_Sonar_Cloud.yml@main
# secrets: inherit
6 changes: 2 additions & 4 deletions .github/workflows/deploy_prod_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ name: Deploy Production App
on:
push:
tags:
- v*.*.*

- v*.*.*
permissions:
contents: read

jobs:
trigger_build_and_test:
name: Triggered Deploy Prod
uses: alexfariakof/Home_Broker_Chart/.github/workflows/build_and_test.yml@main
uses: alexfariakof/app-home-broker-chart/.github/workflows/build_and_test.yml@main
secrets: inherit

deploy:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<EnableHotReload>true</EnableHotReload>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Repository\Repository.csproj" />
<ProjectReference Include="..\Repository\HomeBroker.Repository.csproj" />
</ItemGroup>
</Project>
12 changes: 6 additions & 6 deletions Business/HomeBrokerBusiness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public Sma GetSMA(Period period)
var sma = new Sma(this.GetHistoryData(period).Select(price => price.Close).ToList());
return sma;
}
catch (Exception ex)
catch
{
throw ex;
throw new ArgumentException("Erro ao gerar SMA.");
}
}
public Ema GetEMA(int periodDays, Period period)
Expand All @@ -37,9 +37,9 @@ public Ema GetEMA(int periodDays, Period period)
var ema = new Ema(this.GetHistoryData(period).Select(price => price.Close).ToList(), periodDays);
return ema;
}
catch (Exception ex)
catch
{
throw ex;
throw new ArgumentException("Erro ao gerar EMA.");
}
}
public MACD GetMACD(Period period)
Expand All @@ -49,9 +49,9 @@ public MACD GetMACD(Period period)
var macd = new MACD(this.GetHistoryData(period).Select(price => price.Close).ToList());
return macd;
}
catch (Exception ex)
catch
{
throw ex;
throw new ArgumentException("Erro ao gerar MACD.");
}
}
}
File renamed without changes.
2 changes: 1 addition & 1 deletion HomeBrokerSPA/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ RUN dotnet publish -c Release -o /app/publish /p:UseAppHost=false
FROM mcr.microsoft.com/dotnet/aspnet:8.0 as final
WORKDIR /app
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "HomeBrokerSPA.dll"]
ENTRYPOINT ["dotnet", "HomeBroker.SPA.dll"]
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 as base
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 3002
EXPOSE 3003
RUN dotnet dev-certs https -ep ${HOME}/.aspnet/https/HomeBrokerSPA.pfx -p ${HOME}/.aspnet/https
RUN dotnet dev-certs https --trust

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS publish
WORKDIR /src
Expand All @@ -16,15 +13,15 @@ RUN apt-get update && \
apt-get install -y nodejs
RUN npm install -g [email protected] && \
npm install -g @angular/core@17 @angular/cli@17

RUN dotnet build --restore
RUN dotnet publish -c Release -o /app/publish /p:UseAppHost=false

FROM mcr.microsoft.com/dotnet/aspnet:8.0 as final
WORKDIR /app
ENV ASPNETCORE_ENVIRONMENT=Staging
ENV ASPNETCORE_URLS=http://+3002;https://+3003;
ENV ASPNETCORE_URLS=http://+3002;
ENV ASPNETCORE_HTTP_PORT=3002
ENV ASPNETCORE_HTTPS_PORT=3003

COPY --from=base /root ../root
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "HomeBrokerSPA.dll"]
ENTRYPOINT ["dotnet", "HomeBroker.SPA.dll"]
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 as base
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
RUN dotnet dev-certs https -ep ${HOME}/.aspnet/https/HomeBrokerSPA.pfx -p ${HOME}/.aspnet/https
RUN dotnet dev-certs https --trust

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS publish
WORKDIR /src
Expand All @@ -16,6 +14,8 @@ RUN apt-get update && \
apt-get install -y nodejs
RUN npm install -g [email protected] && \
npm install -g @angular/core@17 @angular/cli@17

RUN dotnet build --restore
RUN dotnet publish -c Release -o /app/publish /p:UseAppHost=false

FROM mcr.microsoft.com/dotnet/aspnet:8.0 as final
Expand All @@ -24,6 +24,5 @@ ENV ASPNETCORE_ENVIRONMENT=Production
ENV ASPNETCORE_URLS=http://+80;https://+443;
ENV ASPNETCORE_HTTPS_PORT=443

COPY --from=base /root ../root
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "HomeBrokerSPA.dll"]
ENTRYPOINT ["dotnet", "HomeBroker.SPA.dll"]
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.SpaProxy" Version="8.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<ProjectReference Include="..\Business\Business.csproj" />
<ProjectReference Include="..\Domain\Domain.csproj" />
<ProjectReference Include="..\Business\HomeBroker.Business.csproj" />
<ProjectReference Include="..\Domain\HomeBroker.Domain.csproj" />
<Folder Include="Controllers\" />
</ItemGroup>

Expand Down
11 changes: 7 additions & 4 deletions HomeBrokerSPA/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,22 @@

var app = builder.Build();

if (app.Environment.IsStaging()) {
if (app.Environment.IsStaging())
{
app.Urls.Add("http://0.0.0.0:3002");
app.Urls.Add("https://0.0.0.0:3003");
}
else if (app.Environment.IsEnvironment("Swagger"))
{
app.Urls.Add("http://127.0.0.1:5000");
app.Urls.Add("https://127.0.0.1:5001");
}
else
{
app.UseHttpsRedirection();
app.UseHsts();
app.UseAuthorization();
}

app.UseHsts();
app.UseSwagger();
app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", $"{appName} {appVersion}"); });

Expand All @@ -54,7 +57,7 @@
option.AddRedirect("^$", "swagger");
app.UseRewriter(option);
}
app.UseAuthorization();

app.MapControllers();
app.UseDefaultFiles();
app.UseStaticFiles();
Expand Down
10 changes: 5 additions & 5 deletions HomeBrokerXUnit/Business/HomeBrokerBusinessTest.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Domain.Charts.ValueObject;
using HomeBrokerXUnit.Faker;
using HomeBrokerXUnit.__mock__;
using Repository.Interfaces;
using Moq;

namespace Business;
public class HomeBrokerBusinessTest
public sealed class HomeBrokerBusinessTest
{

[Fact]
Expand Down Expand Up @@ -100,7 +100,7 @@ public void Should_Throw_Exception_GetSMA()
mockRepository.Setup(repo => repo.GetHistoryData(It.IsAny<Period>())).Throws(new Exception ("GetSMA_WithException_ShouldThrowException"));

// Act & Assert
Assert.Throws<Exception>(() => business.GetSMA(fakePeriod));
Assert.Throws<ArgumentException>(() => business.GetSMA(fakePeriod));
}

[Fact]
Expand All @@ -113,7 +113,7 @@ public void Should_Throw_Exception_GetEMA()
mockRepository.Setup(repo => repo.GetHistoryData(It.IsAny<Period>())).Throws(new Exception ("GetEMA_WithException_ShouldThrowException"));

// Act & Assert
Assert.Throws<Exception >(() => business.GetEMA(10, fakePeriod));
Assert.Throws<ArgumentException >(() => business.GetEMA(10, fakePeriod));
}

[Fact]
Expand All @@ -126,6 +126,6 @@ public void Should_Throw_Exception_GetMACD()
mockRepository.Setup(repo => repo.GetHistoryData(It.IsAny<Period>())).Throws(new Exception ("GetMACD_WithException_ShouldThrowException"));

// Act & Assert
Assert.Throws<Exception >(() => business.GetMACD(fakePeriod));
Assert.Throws<ArgumentException>(() => business.GetMACD(fakePeriod));
}
}
10 changes: 5 additions & 5 deletions HomeBrokerXUnit/Controllers/ChartHomeBrokerControllerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
using Domain.Charts.Agreggates;
using Domain.Charts.ValueObject;
using HomeBrokerSPA.Controllers;
using HomeBrokerXUnit.Faker;
using HomeBrokerXUnit.__mock__;
using Microsoft.AspNetCore.Mvc;
using Moq;

namespace Controllers;
public class ChartHomeBrokerControllerTest
public sealed class ChartHomeBrokerControllerTest
{
[Fact]
public void Should_Returns_List_MagazineLuizaHistoryPrice_Get()
Expand Down Expand Up @@ -124,7 +124,7 @@ public void Should_Return_BadRequest_GetSMA()
Assert.NotNull(result);
Assert.IsType<BadRequestObjectResult>(result);
var value = Assert.IsType<BadRequestObjectResult>(result).Value;
var message = value.GetType().GetProperty("message").GetValue(value, null) as string;
var message = value?.GetType()?.GetProperty("message")?.GetValue(value, null) as string;
Assert.Equal("Get SMA Exeption", message);
}

Expand All @@ -144,7 +144,7 @@ public void Should_Return_BadRequest_GetEMA()
Assert.NotNull(result);
Assert.IsType<BadRequestObjectResult>(result);
var value = Assert.IsType<BadRequestObjectResult>(result).Value;
var message = value.GetType().GetProperty("message").GetValue(value, null) as string;
var message = value?.GetType()?.GetProperty("message")?.GetValue(value, null) as string;
Assert.Equal("Get EMA Exeption", message);
}

Expand All @@ -164,7 +164,7 @@ public void Should_Return_BadRequest_GetMACD()
Assert.NotNull(result);
Assert.IsType<BadRequestObjectResult>(result);
var value = Assert.IsType<BadRequestObjectResult>(result).Value;
var message = value.GetType().GetProperty("message").GetValue(value, null) as string;
var message = value?.GetType()?.GetProperty("message")?.GetValue(value, null) as string;
Assert.Equal("Get MACD Exeption", message);
}
}
2 changes: 1 addition & 1 deletion HomeBrokerXUnit/Domain/EMATest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Domain.Charts.ValueObject;
namespace Domain;
public class EMATest
public sealed class EMATest
{
[Fact]
public void Should_Calculates_EMA_Correctly()
Expand Down
4 changes: 2 additions & 2 deletions HomeBrokerXUnit/Domain/MACDTest.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Domain.Charts.ValueObject;
using HomeBrokerXUnit.Faker;
using HomeBrokerXUnit.__mock__;

namespace Domain;
public class MACDTest
public sealed class MACDTest
{
const int MIN_AMOUNT_DATA = 34;

Expand Down
4 changes: 2 additions & 2 deletions HomeBrokerXUnit/Domain/MagazineLuizaHistoryPriceTest.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Domain.Charts.Agreggates;
using HomeBrokerXUnit.Faker;
using HomeBrokerXUnit.__mock__;

namespace Domain;

public class MagazineLuizaHistoryPriceTest
public sealed class MagazineLuizaHistoryPriceTest
{
[Fact]
public void Should_Create_Instance_MagazineLuizaHistoryPrice()
Expand Down
Loading

0 comments on commit ebbf905

Please sign in to comment.