Skip to content
Open
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
12 changes: 12 additions & 0 deletions Bot.sln
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 12.00
#
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Platform.Bot", "csharp\Platform.Bot\Platform.Bot.csproj", "{81D55AD3-9698-4BEC-B7EC-26ED7B8E6E53}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FileManager", "csharp\FileManager\FileManager.csproj", "{2F40CB1A-A1FD-4433-B998-BC3AEA2EFEB3}"
Expand All @@ -10,6 +11,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Storage", "csharp\Storage\S
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TraderBot", "csharp\TraderBot\TraderBot.csproj", "{FAE89FE2-17C5-4AD6-98EC-84002CC4C672}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "csharp", "csharp", "{5B274C13-EB2B-4612-9430-26107BEFA67F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Platform.Bot.Tests", "csharp\Platform.Bot.Tests\Platform.Bot.Tests.csproj", "{F3D39934-E504-4B61-91DB-B37F654B7925}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -36,5 +41,12 @@ Global
{FAE89FE2-17C5-4AD6-98EC-84002CC4C672}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FAE89FE2-17C5-4AD6-98EC-84002CC4C672}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FAE89FE2-17C5-4AD6-98EC-84002CC4C672}.Release|Any CPU.Build.0 = Release|Any CPU
{F3D39934-E504-4B61-91DB-B37F654B7925}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F3D39934-E504-4B61-91DB-B37F654B7925}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F3D39934-E504-4B61-91DB-B37F654B7925}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F3D39934-E504-4B61-91DB-B37F654B7925}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{F3D39934-E504-4B61-91DB-B37F654B7925} = {5B274C13-EB2B-4612-9430-26107BEFA67F}
EndGlobalSection
EndGlobal
55 changes: 55 additions & 0 deletions csharp/Platform.Bot.Tests/GoogleSearchErrorTriggerTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System.Threading.Tasks;
using Moq;
using Platform.Bot.Triggers;
using Storage.Remote.GitHub;
using Xunit;

namespace Platform.Bot.Tests
{
/// <summary>
/// <para>
/// Tests for the GoogleSearchErrorTrigger class.
/// </para>
/// <para></para>
/// </summary>
public class GoogleSearchErrorTriggerTests
{
/// <summary>
/// <para>
/// Tests that the trigger can be instantiated without errors.
/// </para>
/// <para></para>
/// </summary>
[Fact]
public void Constructor_WithValidStorage_CreatesInstance()
{
// Arrange
var mockStorage = new Mock<GitHubStorage>("testuser", "testtoken", "testapp");

// Act
var trigger = new GoogleSearchErrorTrigger(mockStorage.Object);

// Assert
Assert.NotNull(trigger);
}

/// <summary>
/// <para>
/// Tests that the class has the expected public methods.
/// </para>
/// <para></para>
/// </summary>
[Fact]
public void PublicMethods_AreAvailable()
{
// Arrange
var mockStorage = new Mock<GitHubStorage>("testuser", "testtoken", "testapp");
var trigger = new GoogleSearchErrorTrigger(mockStorage.Object);

// Act & Assert - Just verify methods exist and can be called
Assert.NotNull(trigger.GetType().GetMethod("Condition"));
Assert.NotNull(trigger.GetType().GetMethod("Action"));
Assert.NotNull(trigger.GetType().GetMethod("Dispose"));
}
}
}
24 changes: 24 additions & 0 deletions csharp/Platform.Bot.Tests/Platform.Bot.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.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="Moq" Version="4.20.69" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Platform.Bot\Platform.Bot.csproj" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions csharp/Platform.Bot/Platform.Bot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<PackageReference Include="Platform.Data.Doublets.Sequences" Version="0.1.1" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="System.CommandLine.Parser" Version="0.1.1" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion csharp/Platform.Bot/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private static async Task<int> Main(string[] args)
var dbContext = new FileStorage(databaseFilePath?.FullName ?? new TemporaryFile().Filename);
Console.WriteLine($"Bot has been started. {Environment.NewLine}Press CTRL+C to close");
var githubStorage = new GitHubStorage(githubUserName, githubApiToken, githubApplicationName);
var issueTracker = new IssueTracker(githubStorage, new HelloWorldTrigger(githubStorage, dbContext, fileSetName), new OrganizationLastMonthActivityTrigger(githubStorage), new LastCommitActivityTrigger(githubStorage), new AdminAuthorIssueTriggerDecorator(new ProtectDefaultBranchTrigger(githubStorage), githubStorage), new AdminAuthorIssueTriggerDecorator(new ChangeOrganizationRepositoriesDefaultBranchTrigger(githubStorage, dbContext), githubStorage), new AdminAuthorIssueTriggerDecorator(new ChangeOrganizationPullRequestsBaseBranchTrigger(githubStorage, dbContext), githubStorage));
var issueTracker = new IssueTracker(githubStorage, new HelloWorldTrigger(githubStorage, dbContext, fileSetName), new GoogleSearchErrorTrigger(githubStorage), new OrganizationLastMonthActivityTrigger(githubStorage), new LastCommitActivityTrigger(githubStorage), new AdminAuthorIssueTriggerDecorator(new ProtectDefaultBranchTrigger(githubStorage), githubStorage), new AdminAuthorIssueTriggerDecorator(new ChangeOrganizationRepositoriesDefaultBranchTrigger(githubStorage, dbContext), githubStorage), new AdminAuthorIssueTriggerDecorator(new ChangeOrganizationPullRequestsBaseBranchTrigger(githubStorage, dbContext), githubStorage));
var pullRequenstTracker = new PullRequestTracker(githubStorage, new MergeDependabotBumpsTrigger(githubStorage));
var timestampTracker = new DateTimeTracker(githubStorage, new CreateAndSaveOrganizationRepositoriesMigrationTrigger(githubStorage, dbContext, Path.Combine(Directory.GetCurrentDirectory(), "/github-migrations")));
var cancellation = new CancellationTokenSource();
Expand Down
Loading
Loading