Преглед на файлове

implemented base repository for mongo services

feature/room-repository-with-interface
meris.ahmatovic преди 3 години
родител
ревизия
908ee21d80
променени са 100 файла, в които са добавени 264 реда и са изтрити 6 реда
  1. 11
    0
      Backend/Diligent.WebAPI.Business/Interfaces/IBaseRepository.cs
  2. 14
    0
      Backend/Diligent.WebAPI.Business/Interfaces/IRequestRepository.cs
  3. 42
    0
      Backend/Diligent.WebAPI.Business/Services/BaseRepository.cs
  4. 28
    0
      Backend/Diligent.WebAPI.Business/Services/RequestRepository.cs
  5. 14
    0
      Backend/Diligent.WebAPI.Data/DbContext/IMongoDbContext.cs
  6. 25
    0
      Backend/Diligent.WebAPI.Data/DbContext/MongoDBContext.cs
  7. 1
    0
      Backend/Diligent.WebAPI.Host/Diligent.WebAPI.Host.csproj
  8. 5
    1
      Backend/Diligent.WebAPI.Host/Extensions/WebAppBuilder.cs
  9. 5
    5
      Backend/Diligent.WebAPI.Host/Mediator/Request/Handlers/GetAllRequestHandler.cs
  10. 6
    0
      Backend/Diligent.WebAPI.Host/Program.cs
  11. 6
    0
      Backend/Diligent.WebAPI.sln
  12. 64
    0
      Backend/Tests/CustomerServiceTest.cs
  13. 26
    0
      Backend/Tests/Tests.csproj
  14. 16
    0
      Backend/Tests/UnitTest1.cs
  15. 1
    0
      Backend/Tests/Usings.cs
  16. Двоични данни
      Backend/Tests/bin/Debug/net6.0/AspNetCore.Identity.MongoDbCore.dll
  17. Двоични данни
      Backend/Tests/bin/Debug/net6.0/AutoMapper.Extensions.Microsoft.DependencyInjection.dll
  18. Двоични данни
      Backend/Tests/bin/Debug/net6.0/AutoMapper.dll
  19. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Castle.Core.dll
  20. Двоични данни
      Backend/Tests/bin/Debug/net6.0/CoverletSourceRootsMapping
  21. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Diligent.WebAPI.Business.dll
  22. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Diligent.WebAPI.Business.pdb
  23. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Diligent.WebAPI.Data.dll
  24. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Diligent.WebAPI.Data.pdb
  25. Двоични данни
      Backend/Tests/bin/Debug/net6.0/DnsClient.dll
  26. Двоични данни
      Backend/Tests/bin/Debug/net6.0/FluentAssertions.dll
  27. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Authentication.Abstractions.dll
  28. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Authentication.Core.dll
  29. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Connections.Abstractions.dll
  30. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Cryptography.Internal.dll
  31. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Cryptography.KeyDerivation.dll
  32. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Diagnostics.Abstractions.dll
  33. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Diagnostics.dll
  34. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.HostFiltering.dll
  35. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Hosting.Abstractions.dll
  36. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Hosting.Server.Abstractions.dll
  37. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Hosting.dll
  38. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Http.Abstractions.dll
  39. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Http.Extensions.dll
  40. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Http.Features.dll
  41. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Http.dll
  42. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.HttpOverrides.dll
  43. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Routing.Abstractions.dll
  44. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Routing.dll
  45. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Server.IIS.dll
  46. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Server.IISIntegration.dll
  47. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Server.Kestrel.Core.dll
  48. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Server.Kestrel.Https.dll
  49. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.dll
  50. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.dll
  51. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Server.Kestrel.dll
  52. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.WebUtilities.dll
  53. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.dll
  54. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Data.SqlClient.dll
  55. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.EntityFrameworkCore.Abstractions.dll
  56. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.EntityFrameworkCore.Relational.dll
  57. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.EntityFrameworkCore.SqlServer.dll
  58. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.EntityFrameworkCore.dll
  59. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Caching.Abstractions.dll
  60. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Caching.Memory.dll
  61. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Configuration.Abstractions.dll
  62. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Configuration.Binder.dll
  63. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Configuration.CommandLine.dll
  64. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Configuration.EnvironmentVariables.dll
  65. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Configuration.FileExtensions.dll
  66. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Configuration.Json.dll
  67. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Configuration.UserSecrets.dll
  68. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Configuration.dll
  69. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll
  70. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.DependencyInjection.dll
  71. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.FileProviders.Abstractions.dll
  72. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.FileProviders.Physical.dll
  73. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.FileSystemGlobbing.dll
  74. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Hosting.Abstractions.dll
  75. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Identity.Core.dll
  76. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Identity.Stores.dll
  77. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Logging.Abstractions.dll
  78. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Logging.Configuration.dll
  79. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Logging.Console.dll
  80. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Logging.Debug.dll
  81. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Logging.EventSource.dll
  82. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Logging.dll
  83. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.ObjectPool.dll
  84. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Options.ConfigurationExtensions.dll
  85. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Options.dll
  86. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Primitives.dll
  87. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Identity.Client.dll
  88. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.IdentityModel.JsonWebTokens.dll
  89. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.IdentityModel.Logging.dll
  90. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.IdentityModel.Protocols.OpenIdConnect.dll
  91. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.IdentityModel.Protocols.dll
  92. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.IdentityModel.Tokens.dll
  93. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.Net.Http.Headers.dll
  94. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.TestPlatform.CommunicationUtilities.dll
  95. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.TestPlatform.CoreUtilities.dll
  96. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.TestPlatform.CrossPlatEngine.dll
  97. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.TestPlatform.PlatformAbstractions.dll
  98. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.TestPlatform.Utilities.dll
  99. Двоични данни
      Backend/Tests/bin/Debug/net6.0/Microsoft.VisualStudio.CodeCoverage.Shim.dll
  100. 0
    0
      Backend/Tests/bin/Debug/net6.0/Microsoft.VisualStudio.TestPlatform.Common.dll

+ 11
- 0
Backend/Diligent.WebAPI.Business/Interfaces/IBaseRepository.cs Целия файл

namespace Diligent.WebAPI.Business.Interfaces
{
public interface IBaseRepository<TEntity> where TEntity : class
{
Task<List<TEntity>> GetAsync();
Task<TEntity> GetByIdAsync(string id);
Task CreateAsync(TEntity entity);
Task UpdateAsync(string id, TEntity updateEntity);
Task RemoveAsync(string id);
}
}

+ 14
- 0
Backend/Diligent.WebAPI.Business/Interfaces/IRequestRepository.cs Целия файл

using Diligent.WebAPI.Data.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Diligent.WebAPI.Business.Interfaces
{
public interface IRequestRepository : IBaseRepository<Request>
{
Task<List<Request>> GetAll();
}
}

+ 42
- 0
Backend/Diligent.WebAPI.Business/Services/BaseRepository.cs Целия файл

using Diligent.WebAPI.Business.Interfaces;
using Diligent.WebAPI.Data;
using MongoDB.Driver;

namespace Diligent.WebAPI.Business.Services
{
public class BaseRepository<TEntity> : IBaseRepository<TEntity> where TEntity : class
{
protected readonly IMongoDBContext _mongoContext;
protected IMongoCollection<TEntity> _dbCollection;
public BaseRepository(IMongoDBContext context)
{
_mongoContext = context;
_dbCollection = _mongoContext.GetCollection<TEntity>(typeof(TEntity).Name);
}

public Task CreateAsync(TEntity entity)
{
throw new NotImplementedException();
}

public async Task<List<TEntity>> GetAsync()
{
var all = await _dbCollection.FindAsync(Builders<TEntity>.Filter.Empty);
return await all.ToListAsync();
}
public Task<TEntity> GetByIdAsync(string id)
{
throw new NotImplementedException();
}

public Task RemoveAsync(string id)
{
throw new NotImplementedException();
}

public Task UpdateAsync(string id, TEntity updateEntity)
{
throw new NotImplementedException();
}
}
}

+ 28
- 0
Backend/Diligent.WebAPI.Business/Services/RequestRepository.cs Целия файл

using Diligent.WebAPI.Business.Interfaces;
using Diligent.WebAPI.Data;
using Diligent.WebAPI.Data.Entities;
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Diligent.WebAPI.Business.Services
{
public class RequestRepository : BaseRepository<Request>, IRequestRepository
{
protected new IMongoCollection<Request> _dbCollection;

public RequestRepository(IMongoDBContext context) : base(context)
{
_dbCollection = _mongoContext.GetCollection<Request>(typeof(Request).Name);
}

public async Task<List<Request>> GetAll()
{
var all = await _dbCollection.FindAsync(Builders<Request>.Filter.Empty);
return await all.ToListAsync();
}
}
}

+ 14
- 0
Backend/Diligent.WebAPI.Data/DbContext/IMongoDbContext.cs Целия файл

using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Diligent.WebAPI.Data
{
public interface IMongoDBContext
{
IMongoCollection<Request> GetCollection<Request>(string id);
}
}

+ 25
- 0
Backend/Diligent.WebAPI.Data/DbContext/MongoDBContext.cs Целия файл

using MongoDB.Driver;

namespace Diligent.WebAPI.Data
{
public class MongoDBContext : IMongoDBContext
{
private readonly IConfiguration _configuration;

private IMongoDatabase _db { get; set; }
private MongoClient _mongoClient { get; set; }
public IClientSessionHandle Session { get; set; }
public MongoDBContext(IConfiguration configuration)
{
_configuration = configuration;
var mongoDbSettings = _configuration.GetSection("WebApiDB");
_mongoClient = new MongoClient(mongoDbSettings["ConnectionString"]);
_db = _mongoClient.GetDatabase(mongoDbSettings["DatabaseName"]);
}

public IMongoCollection<Request> GetCollection<Request>(string id)
{
return _db.GetCollection<Request>(id);
}
}
}

+ 1
- 0
Backend/Diligent.WebAPI.Host/Diligent.WebAPI.Host.csproj Целия файл

<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" /> <PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" /> <PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="5.1.1" /> <PackageReference Include="Serilog.Sinks.Seq" Version="5.1.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup> </ItemGroup>


<ItemGroup> <ItemGroup>

+ 5
- 1
Backend/Diligent.WebAPI.Host/Extensions/WebAppBuilder.cs Целия файл

builder.Configuration.GetSection("WebApiDB")); builder.Configuration.GetSection("WebApiDB"));


builder.Services.AddAutoMapper(typeof(RequestMappingProfile)); builder.Services.AddAutoMapper(typeof(RequestMappingProfile));
builder.Services.AddScoped<IAuthenticationService, AuthenticationService>();


builder.Services.AddScoped(typeof(IBaseRepository<>), typeof(BaseRepository<>));
builder.Services.AddScoped<IRequestRepository, RequestRepository>();
builder.Services.AddScoped<IMongoDBContext, MongoDBContext>();
builder.Services.AddScoped<IAuthenticationService, AuthenticationService>();
builder.Services.AddScoped<ICustomerService, CustomerService>(); builder.Services.AddScoped<ICustomerService, CustomerService>();

builder.Services.AddSingleton<RoomService>(); builder.Services.AddSingleton<RoomService>();
builder.Services.AddSingleton<RequestService>(); builder.Services.AddSingleton<RequestService>();
builder.Services.AddSingleton<AuthorizationService>(); builder.Services.AddSingleton<AuthorizationService>();

+ 5
- 5
Backend/Diligent.WebAPI.Host/Mediator/Request/Handlers/GetAllRequestHandler.cs Целия файл

using Diligent.WebAPI.Business.Services;
using Diligent.WebAPI.Business.Interfaces;
using Diligent.WebAPI.Host.Mediator.Request.Queries; using Diligent.WebAPI.Host.Mediator.Request.Queries;
using MediatR; using MediatR;


{ {
public class GetAllRequestHandler : IRequestHandler<GetAllRequestsQuery, List<Data.Entities.Request>> public class GetAllRequestHandler : IRequestHandler<GetAllRequestsQuery, List<Data.Entities.Request>>
{ {
private readonly RequestService _requestService;
private readonly IRequestRepository _requestRepository;


public GetAllRequestHandler(RequestService requestService)
public GetAllRequestHandler(IRequestRepository requestRepository)
{ {
_requestService = requestService;
_requestRepository = requestRepository;
} }
public async Task<List<Data.Entities.Request>> Handle(GetAllRequestsQuery request, CancellationToken cancellationToken) => public async Task<List<Data.Entities.Request>> Handle(GetAllRequestsQuery request, CancellationToken cancellationToken) =>
await _requestService.GetRequestsAsync();
await _requestRepository.GetAll();
} }
} }

+ 6
- 0
Backend/Diligent.WebAPI.Host/Program.cs Целия файл



builder.ConfigureData(builder.Configuration); builder.ConfigureData(builder.Configuration);
var collection = builder.Services; var collection = builder.Services;
builder.Services.AddSwaggerGen();
Diligent.WebAPI.Host.Extensions.ApiConfiguration.ConfigureServices(collection); Diligent.WebAPI.Host.Extensions.ApiConfiguration.ConfigureServices(collection);
builder.ConfigureValidationMiddleware(); builder.ConfigureValidationMiddleware();
var app = builder.Build(); var app = builder.Build();
app.UseAuthentication(); app.UseAuthentication();
app.UseAuthorization(); app.UseAuthorization();
app.SetupData(); app.SetupData();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}


app.MapHub<ChatHub>("/chatHub"); app.MapHub<ChatHub>("/chatHub");
app.MapHub<ConnectionHub>("/statusHub"); app.MapHub<ConnectionHub>("/statusHub");

+ 6
- 0
Backend/Diligent.WebAPI.sln Целия файл

.editorconfig = .editorconfig .editorconfig = .editorconfig
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{52163977-0F9F-4318-9C98-401D4F31AA65}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
{69367FC8-603A-4E4B-BAD7-99D24308D5F2}.Debug|Any CPU.Build.0 = Debug|Any CPU {69367FC8-603A-4E4B-BAD7-99D24308D5F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69367FC8-603A-4E4B-BAD7-99D24308D5F2}.Release|Any CPU.ActiveCfg = Release|Any CPU {69367FC8-603A-4E4B-BAD7-99D24308D5F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69367FC8-603A-4E4B-BAD7-99D24308D5F2}.Release|Any CPU.Build.0 = Release|Any CPU {69367FC8-603A-4E4B-BAD7-99D24308D5F2}.Release|Any CPU.Build.0 = Release|Any CPU
{52163977-0F9F-4318-9C98-401D4F31AA65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{52163977-0F9F-4318-9C98-401D4F31AA65}.Debug|Any CPU.Build.0 = Debug|Any CPU
{52163977-0F9F-4318-9C98-401D4F31AA65}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52163977-0F9F-4318-9C98-401D4F31AA65}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

+ 64
- 0
Backend/Tests/CustomerServiceTest.cs Целия файл

using Diligent.WebAPI.Business.Services;
using Diligent.WebAPI.Data.Entities;
using FluentAssertions;
using Microsoft.AspNetCore.Identity;
using Moq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tests
{
[TestFixture]
public class CustomerServiceTest
{
private CustomerService service;

[Test]
public async Task DeleteNotification_WhenUserIsNull_ReturnsFalse()
{
// Arrange
var userManagerMock = new Mock<UserManager<Customer>>(Mock.Of<IUserStore<Customer>>(), null, null, null, null, null, null, null, null);
userManagerMock.Setup(x => x.FindByIdAsync(It.IsAny<string>())).ReturnsAsync((Customer)null);

service = new CustomerService(userManagerMock.Object);

// Act
var result = await service.DeleteNotification("", "");

// Assert
//Assert.IsFalse(result);
result.Should().BeFalse();
}

[Test]
public async Task DeleteNotification_UserIsNotNullAndNotificationIsNull_ReturnsFalse()
{
// Arrange
var userManagerMock = new Mock<UserManager<Customer>>(Mock.Of<IUserStore<Customer>>(), null, null, null, null, null, null, null, null);
var customer = new Customer
{
FirstName = "User",
LastName = "Someone",
Notifications = new List<Notification>
{
new Notification
{
RoomId = "Room1", Count = 1
}
}
};
userManagerMock.Setup(x => x.FindByIdAsync(It.IsAny<string>())).ReturnsAsync(customer);

service = new CustomerService(userManagerMock.Object);

// Act
var result = await service.DeleteNotification("arg", "Room1");

// Assert
result.Should().BeTrue();
}
}
}

+ 26
- 0
Backend/Tests/Tests.csproj Целия файл

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="Moq" Version="4.18.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="NUnit.Analyzers" Version="3.3.0" />
<PackageReference Include="coverlet.collector" Version="3.1.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Diligent.WebAPI.Business\Diligent.WebAPI.Business.csproj" />
<ProjectReference Include="..\Diligent.WebAPI.Data\Diligent.WebAPI.Data.csproj" />
</ItemGroup>

</Project>

+ 16
- 0
Backend/Tests/UnitTest1.cs Целия файл

namespace Tests
{
public class Tests
{
[SetUp]
public void Setup()
{
}

[Test]
public void Test1()
{
Assert.Pass();
}
}
}

+ 1
- 0
Backend/Tests/Usings.cs Целия файл

global using NUnit.Framework;

Двоични данни
Backend/Tests/bin/Debug/net6.0/AspNetCore.Identity.MongoDbCore.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/AutoMapper.Extensions.Microsoft.DependencyInjection.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/AutoMapper.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Castle.Core.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/CoverletSourceRootsMapping Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Diligent.WebAPI.Business.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Diligent.WebAPI.Business.pdb Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Diligent.WebAPI.Data.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Diligent.WebAPI.Data.pdb Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/DnsClient.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/FluentAssertions.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Authentication.Abstractions.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Authentication.Core.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Connections.Abstractions.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Cryptography.Internal.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Cryptography.KeyDerivation.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Diagnostics.Abstractions.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Diagnostics.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.HostFiltering.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Hosting.Abstractions.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Hosting.Server.Abstractions.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Hosting.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Http.Abstractions.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Http.Extensions.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Http.Features.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Http.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.HttpOverrides.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Routing.Abstractions.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Routing.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Server.IIS.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Server.IISIntegration.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Server.Kestrel.Core.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Server.Kestrel.Https.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.Server.Kestrel.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.WebUtilities.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.AspNetCore.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Data.SqlClient.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.EntityFrameworkCore.Abstractions.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.EntityFrameworkCore.Relational.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.EntityFrameworkCore.SqlServer.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.EntityFrameworkCore.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Caching.Abstractions.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Caching.Memory.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Configuration.Abstractions.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Configuration.Binder.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Configuration.CommandLine.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Configuration.EnvironmentVariables.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Configuration.FileExtensions.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Configuration.Json.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Configuration.UserSecrets.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Configuration.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.DependencyInjection.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.FileProviders.Abstractions.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.FileProviders.Physical.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.FileSystemGlobbing.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Hosting.Abstractions.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Identity.Core.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Identity.Stores.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Logging.Abstractions.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Logging.Configuration.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Logging.Console.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Logging.Debug.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Logging.EventSource.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Logging.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.ObjectPool.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Options.ConfigurationExtensions.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Options.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Extensions.Primitives.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Identity.Client.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.IdentityModel.JsonWebTokens.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.IdentityModel.Logging.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.IdentityModel.Protocols.OpenIdConnect.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.IdentityModel.Protocols.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.IdentityModel.Tokens.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.Net.Http.Headers.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.TestPlatform.CommunicationUtilities.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.TestPlatform.CoreUtilities.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.TestPlatform.CrossPlatEngine.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.TestPlatform.PlatformAbstractions.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.TestPlatform.Utilities.dll Целия файл


Двоични данни
Backend/Tests/bin/Debug/net6.0/Microsoft.VisualStudio.CodeCoverage.Shim.dll Целия файл


+ 0
- 0
Backend/Tests/bin/Debug/net6.0/Microsoft.VisualStudio.TestPlatform.Common.dll Целия файл


Някои файлове не бяха показани, защото твърде много файлове са промени

Loading…
Отказ
Запис