Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Commit

Permalink
refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Chu committed Oct 7, 2017
1 parent 43af39d commit 074ce07
Show file tree
Hide file tree
Showing 16 changed files with 31 additions and 53 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Obsidian.Domain;
using Obsidian.Domain.Repositories;
using Obsidian.Foundation.ProcessManagement;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
using Obsidian.Domain;
using Microsoft.Extensions.DependencyInjection;
using Obsidian.Domain;
using Obsidian.Domain.Repositories;
using Obsidian.Foundation;
using Obsidian.Foundation.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace Obsidian.Application.ClientManagement
{
public class ClientService
[Service(ServiceLifetime.Scoped)]
public class ClientManagementService
{
private readonly IClientRepository _repo;
public ClientService(IClientRepository repo)
public ClientManagementService(IClientRepository repo)
{
_repo = repo;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
using Obsidian.Domain;
using Microsoft.Extensions.DependencyInjection;
using Obsidian.Domain;
using Obsidian.Domain.Repositories;
using Obsidian.Foundation;
using Obsidian.Foundation.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace Obsidian.Application.ScopeManagement
{
public class ScopeService
[Service(ServiceLifetime.Scoped)]
public class ScopeManagementService
{
private readonly IPermissionScopeRepository _repo;
public ScopeService(IPermissionScopeRepository repo)
public ScopeManagementService(IPermissionScopeRepository repo)
{
_repo = repo;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
using Obsidian.Application.Dto;
using Microsoft.Extensions.DependencyInjection;
using Obsidian.Application.Dto;
using Obsidian.Domain;
using Obsidian.Domain.Repositories;
using Obsidian.Foundation;
using Obsidian.Foundation.Collections;
using Obsidian.Foundation.DependencyInjection;
using System;
using System.Linq;
using System.Threading.Tasks;

namespace Obsidian.Application.UserManagement
{

[Service(ServiceLifetime.Scoped)]
public class UserManagementService
{
private readonly IUserRepository _repo;
Expand Down
6 changes: 0 additions & 6 deletions src/Obsidian.Application/UserManagementService.cs

This file was deleted.

5 changes: 1 addition & 4 deletions src/Obsidian.Domain/Misc/PropertyClaimGetter.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection;
using System.Security.Claims;
using System.Text;

namespace Obsidian.Domain.Misc
{
Expand Down
6 changes: 1 addition & 5 deletions src/Obsidian.Domain/ObsidianClaim.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Obsidian.Domain
namespace Obsidian.Domain
{
public class ObsidianClaim
{
Expand Down
4 changes: 1 addition & 3 deletions src/Obsidian.Domain/UserProfile.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Security.Claims;

namespace Obsidian.Domain
namespace Obsidian.Domain
{
public class UserProfile
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Obsidian.Foundation.Collections
{
Expand Down
2 changes: 0 additions & 2 deletions src/Obsidian.Foundation/EntityNotFoundException.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Obsidian.Foundation
{
Expand Down
4 changes: 1 addition & 3 deletions src/Obsidian.Foundation/ProcessManagement/SagaBus.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Obsidian.Foundation.Collections;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;

namespace Obsidian.Foundation.ProcessManagement
Expand Down
5 changes: 2 additions & 3 deletions src/Obsidian/Controllers/ApiControllers/ClientsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Obsidian.Authorization;
using Obsidian.Domain.Repositories;
using Obsidian.Foundation;
using Obsidian.Foundation.ProcessManagement;
using Obsidian.Misc;
using Swashbuckle.AspNetCore.SwaggerGen;
using System;
Expand All @@ -20,9 +19,9 @@ namespace Obsidian.Controllers.ApiControllers
public class ClientsController : Controller
{
private readonly IClientRepository _clientRepository;
private readonly ClientService _service;
private readonly ClientManagementService _service;

public ClientsController(IClientRepository repo, ClientService service)
public ClientsController(IClientRepository repo, ClientManagementService service)
{
_clientRepository = repo;
_service = service;
Expand Down
5 changes: 2 additions & 3 deletions src/Obsidian/Controllers/ApiControllers/ScopesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Obsidian.Authorization;
using Obsidian.Domain.Repositories;
using Obsidian.Foundation;
using Obsidian.Foundation.ProcessManagement;
using Obsidian.Misc;
using System;
using System.Threading.Tasks;
Expand All @@ -18,9 +17,9 @@ namespace Obsidian.Controllers.ApiControllers
public class ScopesController : Controller
{
private readonly IPermissionScopeRepository _scopeRepository;
private readonly ScopeService _service;
private readonly ScopeManagementService _service;

public ScopesController(IPermissionScopeRepository scopeRepo, ScopeService service)
public ScopesController(IPermissionScopeRepository scopeRepo, ScopeManagementService service)
{
_scopeRepository = scopeRepo;
_service = service;
Expand Down
1 change: 0 additions & 1 deletion src/Obsidian/IdentityConfig.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
Expand Down
6 changes: 1 addition & 5 deletions src/Obsidian/Models/InitializationInfo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;

namespace Obsidian.Models
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
using Obsidian.Domain.Repositories;
using Obsidian.Foundation;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Xunit;

Expand All @@ -17,7 +15,7 @@ public class ClientManagementServiceTest
public async Task CreateTest()
{
var mockRepo = new Mock<IClientRepository>();
var service = new ClientService(mockRepo.Object);
var service = new ClientManagementService(mockRepo.Object);
await service.CreateClient("xxx", "http://xxx.com");
mockRepo.Verify(r => r.AddAsync(It.IsAny<Client>()));
}
Expand All @@ -27,7 +25,7 @@ public async Task Should_Throw_When_Entity_NotFound()
{
var mockRepo = new Mock<IClientRepository>();
mockRepo.Setup(r => r.FindByIdAsync(It.IsAny<Guid>())).Returns(Task.FromResult<Client>(null));
var service = new ClientService(mockRepo.Object);
var service = new ClientManagementService(mockRepo.Object);
await Assert.ThrowsAsync<EntityNotFoundException>(() => service.UpdateClient(Guid.NewGuid(), "xxx", "xxx"));
await Assert.ThrowsAsync<EntityNotFoundException>(() => service.UpdateClientSecret(Guid.NewGuid()));
}
Expand All @@ -41,7 +39,7 @@ public async Task UpdateSecretTest()
var mockRepo = new Mock<IClientRepository>();
mockRepo.Setup(r => r.FindByIdAsync(It.Is<Guid>(i => i == id)))
.Returns(Task.FromResult(client));
var service = new ClientService(mockRepo.Object);
var service = new ClientManagementService(mockRepo.Object);
var newClient = await service.UpdateClientSecret(id);
Assert.NotEqual(secret, newClient.Secret);
}
Expand All @@ -58,7 +56,7 @@ public async Task UpdateClientTest()
.Callback<Client>(c => client = c)
.Returns(Task.CompletedTask);
client.RedirectUri = new Uri("http://zzz.com");
var service = new ClientService(mockRepo.Object);
var service = new ClientManagementService(mockRepo.Object);
const string newUri = "http://yyy.com";
await service.UpdateClient(id, "aaa", newUri);
Assert.Equal(newUri, client.RedirectUri.OriginalString);
Expand Down

0 comments on commit 074ce07

Please sign in to comment.