Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions Lacuna.FocusNFSeIntegration.AppTest/Classes/TestHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using Lacuna.FocusNFSeIntegration;
using Lacuna.FocusNFSeIntegration.Models;
using Lacuna.FocusNFSeIntegration.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Lacuna.FocusNFeIntegration.AppTest.Classes {
namespace Lacuna.FocusNFSeIntegration.AppTest.Classes {
public class TestHelpers {

public static NFSeRequest GenerateRequest(FocusNFSeIntegrationOptions options, bool hasCnpj = true) {
Expand All @@ -31,7 +28,7 @@ public static ServiceInfo GenerateServiceInfo(FocusNFSeIntegrationOptions option
}

public static ClientInfo GenerateClientInfo(FocusNFSeIntegrationOptions options, bool hasCnpj = true) {
var info = new ClientInfo {
var info = new ClientInfo {
CompanyNameOrClientName = "LACUNA SOFTWARE LTDA - EPP",
Email = "adm@lacunasoftware.com",
AddressInfo = new AddressInfo {
Expand All @@ -50,7 +47,7 @@ public static ClientInfo GenerateClientInfo(FocusNFSeIntegrationOptions options,
info.StateSubscription = "144408646118";
} else {
info.Cpf = "55500000160";
}
}

return info;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using Lacuna.FocusNFeIntegration.AppTest.Classes;
using Microsoft.AspNetCore.Http;
using Lacuna.FocusNFSeIntegration.AppTest.Classes;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Lacuna.FocusNFSeIntegration.AppTest.Controllers {
Expand All @@ -21,7 +18,7 @@ public FocusNFSeController(FocusNFSeClient focusClient, IOptions<FocusNFSeIntegr
}

[HttpPost("{reference}")]
public async Task<IActionResult> SubmitNFSeAsync(string reference, [FromQuery]bool hasCnpj = true) {
public async Task<IActionResult> SubmitNFSeAsync(string reference, [FromQuery] bool hasCnpj = true) {
var req = TestHelpers.GenerateRequest(focusOptions.Value, hasCnpj);

var retorno = await focusClient.CreateNFSeAsync(reference, req);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Lacuna.FocusNFSeIntegration.AppTest.Controllers {
[Route("api/[controller]")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
<IsPackable>false</IsPackable>
Expand All @@ -10,15 +10,19 @@

<!-- Set this to true if you enable server-side prerendering -->
<BuildServerSideRenderer>false</BuildServerSideRenderer>
<AssemblyName>Lacuna.FocusNFeIntegration.AppTest</AssemblyName>
<RootNamespace>Lacuna.FocusNFeIntegration.AppTest</RootNamespace>
<AssemblyName>Lacuna.FocusNFSeIntegration.AppTest</AssemblyName>
<RootNamespace>Lacuna.FocusNFSeIntegration.AppTest</RootNamespace>
<UserSecretsId>ae90e351-4401-4819-b96e-5cda579fd657</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.9.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.9.0" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions Lacuna.FocusNFSeIntegration.AppTest/Pages/_ViewImports.cshtml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@using Lacuna.FocusNFSeIntegration
@namespace Lacuna.FocusNFSeIntegration.AppTest.Pages
@using Lacuna.FocusNFSeIntegration.AppTest
@using Lacuna.FocusNFSeIntegration.AppTest.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
7 changes: 0 additions & 7 deletions Lacuna.FocusNFSeIntegration.AppTest/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace Lacuna.FocusNFSeIntegration.AppTest {
public class Program {
Expand Down
32 changes: 12 additions & 20 deletions Lacuna.FocusNFSeIntegration.AppTest/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SpaServices.AngularCli;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

Expand All @@ -16,8 +13,7 @@ public Startup(IConfiguration configuration) {

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services) {
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

services.AddControllersWithViews();
// Configuring the Focus NFSe Integration Options from the appsettings
services.Configure<FocusNFSeIntegrationOptions>(Configuration.GetSection("Focus"));
// Creating the Focus NFSe Integration Client as a Singleton and available for the Services and controllers to use it (Asp.Net Core configuration library option)
Expand All @@ -27,6 +23,9 @@ public void ConfigureServices(IServiceCollection services) {
services.AddSpaStaticFiles(configuration => {
configuration.RootPath = "ClientApp/dist";
});

services.AddEndpointsApiExplorer();
services.AddSwaggerGen();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand All @@ -41,23 +40,16 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) {

app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseSpaStaticFiles();

app.UseMvc(routes => {
routes.MapRoute(
name: "default",
template: "{controller}/{action=Index}/{id?}");
});
app.UseSwagger();
app.UseSwaggerUI();
app.UseRouting();

app.UseSpa(spa => {
// To learn more about options for serving an Angular SPA from ASP.NET Core,
// see https://go.microsoft.com/fwlink/?linkid=864501

spa.Options.SourcePath = "ClientApp";

if (env.IsDevelopment()) {
spa.UseAngularCliServer(npmScript: "start");
}
app.UseEndpoints(endpoints => {
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller}/{action=Index}/{id?}"
);
});
}
}
Expand Down
7 changes: 7 additions & 0 deletions Lacuna.FocusNFSeIntegration/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Lacuna.FocusNFSeIntegration {
public static class Constants {
public static readonly string MediaType = "application/json";
public static readonly string FactoryClientName = "FocusNFSeIntegration:Client";
public static readonly string CharSet = "UTF-8";
}
}
Loading