Commit 45e15216 authored by Super's avatar Super

Remove sample.

parent 9a2aaca3
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
namespace EasyAbp.CacheManagement.Samples
{
public interface ISampleAppService : IApplicationService
{
Task<SampleDto> GetAsync();
Task<SampleDto> GetAuthorizedAsync();
}
}
namespace EasyAbp.CacheManagement.Samples
{
public class SampleDto
{
public int Value { get; set; }
}
}
\ No newline at end of file
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
namespace EasyAbp.CacheManagement.Samples
{
public class SampleAppService : CacheManagementAppService, ISampleAppService
{
public Task<SampleDto> GetAsync()
{
return Task.FromResult(
new SampleDto
{
Value = 42
}
);
}
[Authorize]
public Task<SampleDto> GetAuthorizedAsync()
{
return Task.FromResult(
new SampleDto
{
Value = 42
}
);
}
}
}
\ No newline at end of file
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
namespace EasyAbp.CacheManagement.Samples
{
[RemoteService]
[Route("api/CacheManagement/sample")]
public class SampleController : CacheManagementController, ISampleAppService
{
private readonly ISampleAppService _sampleAppService;
public SampleController(ISampleAppService sampleAppService)
{
_sampleAppService = sampleAppService;
}
[HttpGet]
public async Task<SampleDto> GetAsync()
{
return await _sampleAppService.GetAsync();
}
[HttpGet]
[Route("authorized")]
[Authorize]
public async Task<SampleDto> GetAuthorizedAsync()
{
return await _sampleAppService.GetAsync();
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
......
using System.Threading.Tasks;
using Shouldly;
using Xunit;
namespace EasyAbp.CacheManagement.Samples
{
public class SampleAppService_Tests : CacheManagementApplicationTestBase
{
private readonly ISampleAppService _sampleAppService;
public SampleAppService_Tests()
{
_sampleAppService = GetRequiredService<ISampleAppService>();
}
[Fact]
public async Task GetAsync()
{
var result = await _sampleAppService.GetAsync();
result.Value.ShouldBe(42);
}
[Fact]
public async Task GetAuthorizedAsync()
{
var result = await _sampleAppService.GetAuthorizedAsync();
result.Value.ShouldBe(42);
}
}
}
......@@ -3,7 +3,6 @@ using System.Net.Http;
using System.Threading.Tasks;
using IdentityModel.Client;
using Microsoft.Extensions.Configuration;
using EasyAbp.CacheManagement.Samples;
using Volo.Abp.DependencyInjection;
using Volo.Abp.IdentityModel;
......@@ -11,16 +10,13 @@ namespace EasyAbp.CacheManagement
{
public class ClientDemoService : ITransientDependency
{
private readonly ISampleAppService _sampleAppService;
private readonly IIdentityModelAuthenticationService _authenticationService;
private readonly IConfiguration _configuration;
public ClientDemoService(
ISampleAppService sampleAppService,
IIdentityModelAuthenticationService authenticationService,
IConfiguration configuration)
{
_sampleAppService = sampleAppService;
_authenticationService = authenticationService;
_configuration = configuration;
}
......@@ -40,12 +36,6 @@ namespace EasyAbp.CacheManagement
{
Console.WriteLine();
Console.WriteLine($"***** {nameof(TestWithDynamicProxiesAsync)} *****");
var result = await _sampleAppService.GetAsync();
Console.WriteLine("Result: " + result.Value);
result = await _sampleAppService.GetAuthorizedAsync();
Console.WriteLine("Result (authorized): " + result.Value);
}
/* Shows how to use HttpClient to perform a request to the HTTP API.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment