Skip to content

Commit

Permalink
upgrade to dotnet 8
Browse files Browse the repository at this point in the history
  • Loading branch information
panfilenok-epam committed Sep 7, 2024
1 parent 089b87d commit 47f8d50
Show file tree
Hide file tree
Showing 13 changed files with 144 additions and 144 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

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

Expand Down
86 changes: 43 additions & 43 deletions LostFilmMonitoring.BLL/ImageMagickImageProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
// <copyright file="ImageMagickImageProcessor.cs" company="Alexander Panfilenok">
// MIT License
// Copyright (c) 2023 Alexander Panfilenok
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the 'Software'), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// </copyright>

namespace LostFilmMonitoring.BLL;

/// <summary>
/// Responsible for compressing images.
/// </summary>
public class ImageMagickImageProcessor : IImageProcessor
{
/// <inheritdoc/>
public async Task<MemoryStream> CompressImageAsync(Stream imageStream, int quality = 75, int width = 420, int height = 630)
{
using var image = new MagickImage(imageStream);
var size = new MagickGeometry(width, height);
size.IgnoreAspectRatio = true;
image.Resize(size);
image.Quality = quality;
var ms = new MemoryStream();
await image.WriteAsync(ms);
return ms;
}
}
// <copyright file="ImageMagickImageProcessor.cs" company="Alexander Panfilenok">
// MIT License
// Copyright (c) 2023 Alexander Panfilenok
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the 'Software'), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// </copyright>

namespace LostFilmMonitoring.BLL;

/// <summary>
/// Responsible for compressing images.
/// </summary>
public class ImageMagickImageProcessor : IImageProcessor
{
/// <inheritdoc/>
public async Task<MemoryStream> CompressImageAsync(Stream imageStream, int quality = 75, int width = 420, int height = 630)
{
using var image = new MagickImage(imageStream);
var size = new MagickGeometry((uint)width, (uint)height);
size.IgnoreAspectRatio = true;
image.Resize(size);
image.Quality = (uint)quality;
var ms = new MemoryStream();
await image.WriteAsync(ms);
return ms;
}
}
2 changes: 1 addition & 1 deletion LostFilmMonitoring.BLL/LostFilmMonitoring.BLL.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion LostFilmMonitoring.Common/LostFilmMonitoring.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,90 +1,90 @@
// <copyright file="AzureBlobStorageTorrentFileDaoTests.cs" company="Alexander Panfilenok">
// MIT License
// Copyright (c) 2023 Alexander Panfilenok
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the 'Software'), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// </copyright>

namespace LostFilmMonitoring.DAO.Azure.Tests;

[ExcludeFromCodeCoverage]
public class AzureBlobStorageTorrentFileDaoTests
{
Mock<IAzureBlobStorageClient>? azureBlobStorageClient;
private Mock<Common.ILogger>? logger;

[SetUp]
public void Setup()
{
this.azureBlobStorageClient = new Mock<IAzureBlobStorageClient>();
this.logger = new();
this.logger.Setup(l => l.CreateScope(It.IsAny<string>())).Returns(this.logger.Object);
}

[Test]
public async Task DeleteUserFileAsync_should_call_DeleteAsync()
{
var userId = "userId";
var torrentFileName = "torrentFileName";
var dao = new AzureBlobStorageTorrentFileDao(this.azureBlobStorageClient!.Object, this.logger!.Object);
await dao.DeleteUserFileAsync(userId, torrentFileName);
this.azureBlobStorageClient.Verify(x => x.DeleteAsync("usertorrents", userId, torrentFileName), Times.Once);
}

[Test]
public async Task LoadBaseFileAsync_should_return_null()
{
var torrentId = "torrentId";
var dao = new AzureBlobStorageTorrentFileDao(this.azureBlobStorageClient!.Object, this.logger!.Object);
this.azureBlobStorageClient.Setup(x => x.DownloadAsync("basetorrents", $"{torrentId}.torrent")).ReturnsAsync(null as Stream);
var result = await dao.LoadBaseFileAsync(torrentId);
this.azureBlobStorageClient.Verify(x => x.DownloadAsync("basetorrents", $"{torrentId}.torrent"), Times.Once);
Assert.Null(result);
}

[Test]
public async Task LoadBaseFileAsync_should_return_TorrentFile()
{
var torrentId = "torrentId";
var dao = new AzureBlobStorageTorrentFileDao(this.azureBlobStorageClient!.Object, this.logger!.Object);
this.azureBlobStorageClient.Setup(x => x.DownloadAsync("basetorrents", $"{torrentId}.torrent")).ReturnsAsync(new MemoryStream());
var result = await dao.LoadBaseFileAsync(torrentId);
this.azureBlobStorageClient.Verify(x => x.DownloadAsync("basetorrents", $"{torrentId}.torrent"), Times.Once);
Assert.NotNull(result);
Assert.That(string.Equals(result!.FileName, $"{torrentId}.torrent"));
}

[Test]
public async Task SaveBaseFileAsync_should_call_UploadAsync()
{
var torrentId = "torrentId";
var dao = new AzureBlobStorageTorrentFileDao(this.azureBlobStorageClient!.Object, this.logger!.Object);
await dao.SaveBaseFileAsync(torrentId, new TorrentFile(torrentId, new MemoryStream()));
this.azureBlobStorageClient.Verify(x => x.UploadAsync("basetorrents", $"{torrentId}.torrent", It.IsAny<Stream>(), "applications/x-bittorrent", "no-cache"), Times.Once);
}

[Test]
public async Task SaveUserFileAsync_should_call_UploadAsync()
{
var userId = "userId";
var dao = new AzureBlobStorageTorrentFileDao(this.azureBlobStorageClient!.Object, this.logger!.Object);
await dao.SaveUserFileAsync(userId, new TorrentFile("fileName", new MemoryStream()));
this.azureBlobStorageClient.Verify(x => x.UploadAsync("usertorrents", userId, "fileName.torrent", It.IsAny<Stream>(), "applications/x-bittorrent"), Times.Once);
}
}
// <copyright file="AzureBlobStorageTorrentFileDaoTests.cs" company="Alexander Panfilenok">
// MIT License
// Copyright (c) 2023 Alexander Panfilenok
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the 'Software'), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// </copyright>

namespace LostFilmMonitoring.DAO.Azure.Tests;

[ExcludeFromCodeCoverage]
public class AzureBlobStorageTorrentFileDaoTests
{
Mock<IAzureBlobStorageClient>? azureBlobStorageClient;
private Mock<Common.ILogger>? logger;

[SetUp]
public void Setup()
{
this.azureBlobStorageClient = new Mock<IAzureBlobStorageClient>();
this.logger = new();
this.logger.Setup(l => l.CreateScope(It.IsAny<string>())).Returns(this.logger.Object);
}

[Test]
public async Task DeleteUserFileAsync_should_call_DeleteAsync()
{
var userId = "userId";
var torrentFileName = "torrentFileName";
var dao = new AzureBlobStorageTorrentFileDao(this.azureBlobStorageClient!.Object, this.logger!.Object);
await dao.DeleteUserFileAsync(userId, torrentFileName);
this.azureBlobStorageClient.Verify(x => x.DeleteAsync("usertorrents", userId, torrentFileName), Times.Once);
}

[Test]
public async Task LoadBaseFileAsync_should_return_null()
{
var torrentId = "torrentId";
var dao = new AzureBlobStorageTorrentFileDao(this.azureBlobStorageClient!.Object, this.logger!.Object);
this.azureBlobStorageClient.Setup(x => x.DownloadAsync("basetorrents", $"{torrentId}.torrent")).ReturnsAsync(null as Stream);
var result = await dao.LoadBaseFileAsync(torrentId);
this.azureBlobStorageClient.Verify(x => x.DownloadAsync("basetorrents", $"{torrentId}.torrent"), Times.Once);
result.Should().BeNull();
}

[Test]
public async Task LoadBaseFileAsync_should_return_TorrentFile()
{
var torrentId = "torrentId";
var dao = new AzureBlobStorageTorrentFileDao(this.azureBlobStorageClient!.Object, this.logger!.Object);
this.azureBlobStorageClient.Setup(x => x.DownloadAsync("basetorrents", $"{torrentId}.torrent")).ReturnsAsync(new MemoryStream());
var result = await dao.LoadBaseFileAsync(torrentId);
this.azureBlobStorageClient.Verify(x => x.DownloadAsync("basetorrents", $"{torrentId}.torrent"), Times.Once);
result.Should().NotBeNull();
Assert.That(string.Equals(result!.FileName, $"{torrentId}.torrent"));
}

[Test]
public async Task SaveBaseFileAsync_should_call_UploadAsync()
{
var torrentId = "torrentId";
var dao = new AzureBlobStorageTorrentFileDao(this.azureBlobStorageClient!.Object, this.logger!.Object);
await dao.SaveBaseFileAsync(torrentId, new TorrentFile(torrentId, new MemoryStream()));
this.azureBlobStorageClient.Verify(x => x.UploadAsync("basetorrents", $"{torrentId}.torrent", It.IsAny<Stream>(), "applications/x-bittorrent", "no-cache"), Times.Once);
}

[Test]
public async Task SaveUserFileAsync_should_call_UploadAsync()
{
var userId = "userId";
var dao = new AzureBlobStorageTorrentFileDao(this.azureBlobStorageClient!.Object, this.logger!.Object);
await dao.SaveUserFileAsync(userId, new TorrentFile("fileName", new MemoryStream()));
this.azureBlobStorageClient.Verify(x => x.UploadAsync("usertorrents", userId, "fileName.torrent", It.IsAny<Stream>(), "applications/x-bittorrent"), Times.Once);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion LostFilmMonitoring.DAO/LostFilmMonitoring.DAO.Sql.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion LostFilmMonitoring.Infrastructure/azure_function.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ resource functionApp 'Microsoft.Web/sites@2022-03-01' = {
}
]
numberOfWorkers: 1
linuxFxVersion: 'DOTNET-ISOLATED|6.0'
linuxFxVersion: 'DOTNET-ISOLATED|8.0'
ftpsState: 'FtpsOnly'
minTlsVersion: '1.2'
}
Expand Down
2 changes: 1 addition & 1 deletion LostFilmTV.Client.Tests/LostFilmTV.Client.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
Expand Down
2 changes: 1 addition & 1 deletion LostFilmTV.Client/LostFilmTV.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Copyright>MIT</Copyright>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Nullable>enable</Nullable>
Expand Down

0 comments on commit 47f8d50

Please sign in to comment.