Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#
# Build the solution, run the 2 unit tests, then create artifacts.
#
# For more information on GitHub Actions, refer to https://github.com/features/actions
# For a complete CI/CD sample to get started with GitHub Action workflows for Desktop Applications,
# refer to https://github.com/microsoft/github-actions-for-desktop-apps

name: Build and Test

on:
push:
branches: [ "dev", "Extensions.Mocks" ]
pull_request:
branches: [ "dev" ]

jobs:

build:

strategy:
matrix:
configuration: [Release]

runs-on: windows-latest # For a list of available runner types, refer to
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on

env:
Solution_Name: RoboSharp.sln # Replace with your solution name, i.e. MyWpfApp.sln.

steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0

# Install the .NET SDK - https://github.com/actions/setup-dotnet
- name: Install .NET SDK
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
10.0.x

# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v3

- name: Restore
run: dotnet restore $env:Solution_Name

- name: Build
run: dotnet build $env:Solution_Name --configuration ${{ matrix.configuration }} --no-restore

- name: Run RoboSharp Tests
run: dotnet test ./RoboSharpUnitTesting/RoboSharpUnitTesting.csproj --configuration Release --no-build

- name: Run RoboSharp.Extensions Tests
run: dotnet test ./RoboSharp.Extensions.UnitTests/RoboSharp.Extensions.UnitTests.csproj --configuration Release --no-build

# Execute all unit tests in the solution
- name: Execute unit tests
run: dotnet test

- name: Gather Artifacts
run: |
dotnet pack ./RoboSharp/RoboSharp.csproj --configuration Release --no-build --output ./artifacts
dotnet pack ./RoboSharp.Extensions/RoboSharp.Extensions.csproj --configuration Release --no-build --output ./artifacts
dotnet publish ./Robosharp.ConsoleApp/Robosharp.ConsoleApp.csproj --configuration Release --no-build --output ./artifacts/ConsoleApp
dotnet publish ./RoboSharp.BackupApp/RoboSharp.BackupApp.csproj --configuration Release --no-build --output ./artifacts/BackupApp


- name: Upload Artifacts
uses: actions/upload-artifact@v6
with:
name: nuget-packages
path: ./artifacts/*
12 changes: 11 additions & 1 deletion RoboSharp.BackupApp/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,17 @@
<TextBox Grid.Row="4" Text="{Binding JobNameTextbox}" Width="175" Grid.ColumnSpan="1" LostFocus="RefreshQueueListbox" />
</Grid>
<!-- Job Options -->
<StackPanel Margin="34,10,20,10" DataContext="{Binding CommandGenerator}" Name="CopyOptionsExpander">
<Expander Header="Command Types" Margin="34,10,20,0" Background="LightYellow">
<GroupBox>
<StackPanel>
<RadioButton Content="RoboCommand (default)" IsChecked="{Binding CommandFactory.RoboCommand}" />
<RadioButton Content="RoboCommandPortable - StreamedFileCopier" IsChecked="{Binding CommandFactory.RoboCommandPortable_Streamed}" />
<RadioButton Content="RoboCommandPortable - CopyFileEx" IsChecked="{Binding CommandFactory.RoboCommandPortable_CopyFileEx}" />
<RadioButton Content="RoboMover" IsChecked="{Binding CommandFactory.RoboMover}" />
</StackPanel>
</GroupBox>
</Expander>
<StackPanel Margin="34,0,20,10" DataContext="{Binding CommandGenerator}" Name="CopyOptionsExpander">
<Expander Background="LightBlue" Header="Copy Options" DataContext="{Binding Command.CopyOptions}">
<Grid Margin="10">
<Grid.RowDefinitions>
Expand Down
2 changes: 1 addition & 1 deletion RoboSharp.BackupApp/RoboSharp.BackupApp.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net48;net8.0-Windows;net10.0-Windows</TargetFrameworks>
<TargetFrameworks>net8.0-Windows;net10.0-Windows</TargetFrameworks>
<OutputType>WinExe</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
Expand Down
13 changes: 11 additions & 2 deletions RoboSharp.BackupApp/ViewModels/CommandGeneratorViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ namespace RoboSharp.BackupApp.ViewModels
{
internal partial class CommandGeneratorViewModel : ObservableObject
{
public CommandGeneratorViewModel()
public CommandGeneratorViewModel(IRoboCommandFactory factory)
{
this.factory = factory;
ResetOptions();
this.PropertyChanged += PropertyChangedHandler;
System.Windows.Input.CommandManager.RequerySuggested += CommandManager_RequerySuggested;
Expand All @@ -29,6 +30,8 @@ private void CommandManager_RequerySuggested(object sender, EventArgs e)
this.BtnParseCommandOptionsCommand.NotifyCanExecuteChanged();
}

private readonly IRoboCommandFactory factory;

[ObservableProperty] private IRoboCommand _command;
[ObservableProperty] private string runHoursStart;
[ObservableProperty] private string runHoursEnd;
Expand All @@ -46,7 +49,13 @@ private void ResetOptions()
public IRoboCommand GetCommand()
{
UpdateCommandName();
return new RoboCommand(Command);
var cmd = factory.GetRoboCommand();
cmd.CopyOptions = Command.CopyOptions;
cmd.LoggingOptions = Command.LoggingOptions;
cmd.RetryOptions = Command.RetryOptions;
cmd.SelectionOptions = Command.SelectionOptions;
cmd.JobOptions.Merge(Command.JobOptions);
return cmd;
}

private void UpdateCommandName()
Expand Down
20 changes: 19 additions & 1 deletion RoboSharp.BackupApp/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public MainWindowViewModel()
SingleJobHistory = new JobHistoryViewModel();
BatchCommandViewModel = new BatchCommandViewModel();
System.Windows.Input.CommandManager.RequerySuggested += CommandManager_RequerySuggested;
CommandGenerator = new CommandGeneratorViewModel(CommandFactory);
}

private void CommandManager_RequerySuggested(object sender, EventArgs e)
Expand All @@ -34,12 +35,29 @@ private void CommandManager_RequerySuggested(object sender, EventArgs e)
}

public RoboQueueViewModel RoboQueueViewModel { get; } = new RoboQueueViewModel(new RoboQueue("RoboQueue"));
public CommandGeneratorViewModel CommandGenerator { get; } = new CommandGeneratorViewModel();
public CommandGeneratorViewModel CommandGenerator { get; }
public CommandProgressViewModel SingleJobProgress { get; } = new CommandProgressViewModel();
public JobHistoryViewModel SingleJobHistory { get; }
public BatchCommandViewModel BatchCommandViewModel { get; }

public CommandFactoryVM CommandFactory { get; } = new CommandFactoryVM();

public class CommandFactoryVM : RoboSharp.RoboCommandFactory
{
public override IRoboCommand GetRoboCommand()
{
if (RoboCommand) return base.GetRoboCommand();
if (RoboCommandPortable_Streamed) return new Extensions.RoboCommandPortable(Extensions.StreamedCopierFactory.DefaultFactory);
if (RoboCommandPortable_CopyFileEx) return new Extensions.RoboCommandPortable(new Extensions.Windows.CopyFileExFactory());
if (RoboMover) return new Extensions.RoboMover();
return base.GetRoboCommand();
}
public bool RoboCommand { get; set; } = true;
public bool RoboCommandPortable_Streamed { get; set; }
public bool RoboCommandPortable_CopyFileEx { get; set; }
public bool RoboMover { get; set; }
}


#region < RoboCommand Buttons >

Expand Down
34 changes: 0 additions & 34 deletions RoboSharp.Extensions.UnitTests/AssertExtensions.cs

This file was deleted.

9 changes: 6 additions & 3 deletions RoboSharp.Extensions.UnitTests/BatchCommandTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using RoboSharp;
using RoboSharp.Extensions.Helpers;
using RoboSharp.Interfaces;
using RoboSharp.UnitTests;
using System;
Expand All @@ -16,7 +15,10 @@ namespace RoboSharp.Extensions.Tests
[TestClass]
public class BatchCommandTests
{
public TestContext TestContext { get; set; }

[TestMethod]
[Timeout(5000, CooperativeCancellation = true)]
public async Task TestCopyOperation()
{
string destination = TestPrep.GetRandomPath(true);
Expand All @@ -30,7 +32,7 @@ public async Task TestCopyOperation()
cmd.LoggingOptions.IncludeFullPathNames = true;
cmd.Configuration.EnableFileLogging = true;
cmd.AddCopiers(files);
var results = await Test_Setup.RunTest(cmd);
var results = await Test_Setup.RunTest(cmd, TestContext.CancellationToken);
Test_Setup.WriteLogLines(results.Results);
Assert.AreEqual(files.Count(), results.Results.FilesStatistic.Copied); // expect 4
}
Expand All @@ -41,6 +43,7 @@ public async Task TestCopyOperation()
}

[TestMethod]
[Timeout(5000, CooperativeCancellation =true)]
public async Task TestCancellation()
{
CancellationTokenSource cToken = new CancellationTokenSource();
Expand All @@ -62,7 +65,7 @@ public async Task TestCancellation()
};

cmd.OnError += (o, e) => Console.WriteLine(e.Error);
var results = await Test_Setup.RunTest(cmd);
var results = await Test_Setup.RunTest(cmd, TestContext.CancellationToken);
Test_Setup.WriteLogLines(results.Results);
Assert.IsTrue(results.Results.Status.WasCancelled, "Results.Status.WasCancelled flag not set!");
var numCopied = results.Results.FilesStatistic.Copied;
Expand Down
1 change: 0 additions & 1 deletion RoboSharp.Extensions.UnitTests/DirectoryPairTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using RoboSharp;
using RoboSharp.Extensions.Helpers;
using RoboSharp.Interfaces;
using RoboSharp.UnitTests;
using System;
Expand Down
2 changes: 2 additions & 0 deletions RoboSharp.Extensions.UnitTests/Helpers/ResultsBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,11 @@ public void AddFileSkippedTest()

var testFile = new ProcessedFileInfo() { FileClass = cmd.Configuration.LogParsing_NewFile, FileClassType = FileClassType.File, Name = "TestFileName", Size = 100 };
cmd.LoggingOptions.NoFileList = true;
cmd.LoggingOptions.ReportExtraFiles = false;
builder.AddFileSkipped(testFile);
Assert.AreEqual(0, builder.CurrentLogLines.LongLength);
cmd.LoggingOptions.NoFileList = false;
cmd.LoggingOptions.ReportExtraFiles = true;
builder.AddFileSkipped(testFile);
Assert.AreEqual(1, builder.CurrentLogLines.LongLength);
Assert.AreEqual(2, builder.GetResults().FilesStatistic.Skipped);
Expand Down
Loading