Skip to content

Commit

Permalink
Merge pull request #122 from Blazam-App/Beta-Nightly
Browse files Browse the repository at this point in the history
v0.8.2 Update
  • Loading branch information
jacobsen9026 authored May 12, 2023
2 parents 515b8df + c3c6ec6 commit a3d4699
Show file tree
Hide file tree
Showing 790 changed files with 186,914 additions and 18,393 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Restore dependencies
run: dotnet restore
- name: Build application
run: dotnet publish -c Release -o bin/publish
run: dotnet publish -c Release -o bin/publish BLAZAM/BLAZAM.csproj
- name: Test application
run: dotnet test -c Release

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Restore dependencies
run: dotnet restore
- name: Build application
run: dotnet publish -c Release -o bin/publish
run: dotnet publish -c Release -o bin/publish BLAZAM/BLAZAM.csproj
- name: Test application
run: dotnet test -c Release

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: dotnet build --configuration Release

- name: dotnet publish
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp BLAZAM/BLAZAM.csproj

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Restore dependencies
run: dotnet restore
- name: Build application
run: dotnet publish -c Release -o bin\Publish
run: dotnet publish -c Release -o bin\Publish BLAZAM/BLAZAM.csproj
- name: Set assembly version as environment variable
shell: pwsh
id: get_version
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -368,3 +368,5 @@ FodyWeavers.xsd
/BLAZAM/appsettings.json
/Setup/BLAZAM.msi
/BLAZAM/database.db
/BLAZAM/database - Copy.db
/BLAZAM/export
4 changes: 2 additions & 2 deletions BLAZAM.Tests/BLAZAM.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
123 changes: 123 additions & 0 deletions BLAZAM.Tests/FileSystem/FileSystemBaseTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
using BLAZAM.FileSystem;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.AccessControl;
using System.Text;
using System.Threading.Tasks;

namespace BLAZAM.Tests.FileSystem
{
public class FileSystemBaseTests
{
[Fact]
public void Constructor_ThrowsArgumentException_WhenPathIsNull()
{
// Arrange
string path = null;

// Act and Assert
Assert.Throws<ArgumentException>(() => new FileSystemBase(path));
}

[Fact]
public void Constructor_ReplacesTempVariable_WhenPathContainsTemp()
{
// Arrange
string path = "%temp%\\test.txt";

// Act
var fileSystemBase = new FileSystemBase(path);

// Assert
Assert.Equal(Path.GetTempPath() + "test.txt", fileSystemBase.Path);
}

[Fact]
public void Constructor_SetsFullPath_WhenPathIsRelative()
{
// Arrange
string path = "..\\test.txt";

// Act
var fileSystemBase = new FileSystemBase(path);

// Assert
Assert.Equal(Path.GetFullPath(path), fileSystemBase.Path);
}

[Fact]
public void Writable_ReturnsTrue_WhenFileHasWritePermission()
{
// Arrange
string path = Path.GetTempFileName();
var fileSystemBase = new FileSystemBase(path);

// Act
bool writable = fileSystemBase.Writable;

// Assert
Assert.True(writable);

// Clean up
File.Delete(path);
}
//TODO Fix checking when no write permission
//[Fact]
//public void Writable_ReturnsFalse_WhenFileHasNoWritePermission()
//{
// // Arrange
// string path = Path.GetTempFileName();
// var fileSystemBase = new FileSystemBase(path);

// // Deny write permission to the file
// var ac = new FileInfo(path).GetAccessControl();
// ac.AddAccessRule(new FileSystemAccessRule(Environment.UserName, FileSystemRights.Write, AccessControlType.Deny));
// new FileInfo(path).SetAccessControl(ac);

// // Act
// bool writable = fileSystemBase.Writable;

// // Assert
// Assert.False(writable);

// // Clean up
// File.Delete(path);
//}

[Fact]
public void GetHashCode_ReturnsPathHashCode()
{
// Arrange
string path = Path.GetTempFileName();
var fileSystemBase = new FileSystemBase(path);

// Act
int hashCode = fileSystemBase.GetHashCode();

// Assert
Assert.Equal(path.GetHashCode(), hashCode);

// Clean up
File.Delete(path);
}

[Fact]
public void ToString_ReturnsPath()
{
// Arrange
string path = Path.GetTempFileName();
var fileSystemBase = new FileSystemBase(path);

// Act
string toString = fileSystemBase.ToString();

// Assert
Assert.Equal(path, toString);

// Clean up
File.Delete(path);
}
}

}
134 changes: 0 additions & 134 deletions BLAZAM.Tests/Mocks/MockDirectoryModel.cs

This file was deleted.

3 changes: 2 additions & 1 deletion BLAZAM.Tests/Mocks/Mock_HttpClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ internal class Mock_HttpClientFactory : IHttpClientFactory
{
public HttpClient CreateClient(string name)
{
return HttpClientFactory.Create();
HttpClient client = new HttpClient();
return client;
}
}
}
17 changes: 14 additions & 3 deletions BLAZAM.Tests/Mocks/Mock_UpdateService.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
using BLAZAM.Server.Data.Services.Update;

using BLAZAM.Common.Data;
using BLAZAM.FileSystem;
using BLAZAM.Update.Services;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace BLAZAM.Tests.Mocks
{
internal class Mock_UpdateService : UpdateService
{
public Mock_UpdateService() : base(new Mock_HttpClientFactory())
public Mock_UpdateService() : base(new Mock_HttpClientFactory(), new()
{

ApplicationRoot = new SystemDirectory("C:\\temp"),
RunningProcess = Process.GetCurrentProcess(),
RunningVersion = new ApplicationVersion("0.0.1"),
TempDirectory = new SystemDirectory("C:\\temp")
},null)
{

SelectedBranch = "Stable";
}
}
Expand Down
5 changes: 3 additions & 2 deletions BLAZAM.Tests/Updates/UpdateTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using BLAZAM.Server.Data.Services.Update;

using BLAZAM.Tests.Mocks;
using BLAZAM.Update;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -46,7 +47,7 @@ private async void Update_Stages_OK(ApplicationUpdate latest)
private async void Update_Cleanup_OK(ApplicationUpdate latest)
{

latest.CleanStaging();
await latest.CleanStaging();
latest.UpdateFile.Delete();
Assert.True(!latest.UpdateFile.Exists);
Assert.True(latest.UpdateStagingDirectory.Files.Count == 0);
Expand Down
5 changes: 3 additions & 2 deletions BLAZAM.Tests/Updates/VersionTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using BLAZAM.Server.Data;
using BLAZAM.Server.Data.Services.Update;
using BLAZAM.Common.Data;
using BLAZAM.Server.Data;
using BLAZAM.Update;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
Loading

0 comments on commit a3d4699

Please sign in to comment.