Skip to content

Commit

Permalink
Merge pull request #1 from gman-au/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
gubpalma authored Aug 22, 2024
2 parents 9210141 + 083d4a4 commit 4b31e05
Show file tree
Hide file tree
Showing 24 changed files with 432 additions and 191 deletions.
5 changes: 4 additions & 1 deletion src/6.0/Not.Again.Api.Host/Injection/IoCNotAgain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ IConfigurationRoot configuration
{
services
.AddTransient<IResultSubmitter, ResultSubmitter>()
.AddTransient<ITestAssemblyGetter, TestAssemblyGetter>()
.AddTransient<ITestRecordGetter, TestRecordGetter>()
.AddTransient<ITestRunGetter, TestRunGetter>()
.AddTransient<ITestAssemblyGetter, TestAssemblyGetter>()
.AddTransient<ITestAssemblyPutter, TestAssemblyPutter>()
.AddTransient<ITestRecordPutter, TestRecordPutter>()
.AddTransient<ITestRunPutter, TestRunPutter>()
.AddTransient<IRunChecker, RunChecker>()
.AddTransient<IArgumentDelimiter, ArgumentDelimiter>()
.AddTransient<IMessageFormatter, MessageFormatter>();
Expand Down
2 changes: 2 additions & 0 deletions src/6.0/Not.Again.Contracts/TestResultDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ public class TestResultDetails
public long Duration { get; set; }

public DateTime RunDate { get; set; }

public string TestRunner { get; set; }
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ protected override void Up(MigrationBuilder migrationBuilder)
columns: table => new
{
TestAssemblyId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TestAssemblyName = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true)
TestAssemblyName = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true),
TestRunner = table.Column<string>(type: "nvarchar(32)", maxLength: 32, nullable: true)
},
constraints: table =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasMaxLength(512)
.HasColumnType("nvarchar(512)");

b.Property<string>("TestRunner")
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");

b.HasKey("TestAssemblyId");

b.ToTable("TestAssembly");
Expand Down Expand Up @@ -103,7 +107,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
modelBuilder.Entity("Not.Again.Domain.TestRecord", b =>
{
b.HasOne("Not.Again.Domain.TestAssembly", "TestAssembly")
.WithMany()
.WithMany("TestRecords")
.HasForeignKey("TestAssemblyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
Expand All @@ -114,13 +118,23 @@ protected override void BuildModel(ModelBuilder modelBuilder)
modelBuilder.Entity("Not.Again.Domain.TestRun", b =>
{
b.HasOne("Not.Again.Domain.TestRecord", "TestRecord")
.WithMany()
.WithMany("TestRuns")
.HasForeignKey("TestRecordId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();

b.Navigation("TestRecord");
});

modelBuilder.Entity("Not.Again.Domain.TestAssembly", b =>
{
b.Navigation("TestRecords");
});

modelBuilder.Entity("Not.Again.Domain.TestRecord", b =>
{
b.Navigation("TestRuns");
});
#pragma warning restore 612, 618
}
}
Expand Down
1 change: 1 addition & 0 deletions src/6.0/Not.Again.Database/Not.Again.Database.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

<ItemGroup>
<ProjectReference Include="..\Not.Again.Domain\Not.Again.Domain.csproj"/>
<ProjectReference Include="..\Not.Again.Enum\Not.Again.Enum.csproj" />
<ProjectReference Include="..\Not.Again.Infrastructure\Not.Again.Infrastructure.csproj" />
<ProjectReference Include="..\Not.Again.Interfaces\Not.Again.Interfaces.csproj"/>
</ItemGroup>
Expand Down
170 changes: 0 additions & 170 deletions src/6.0/Not.Again.Database/ResultSubmitter.cs

This file was deleted.

57 changes: 57 additions & 0 deletions src/6.0/Not.Again.Database/TestAssemblyPutter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System.Threading.Tasks;
using Not.Again.Domain;
using Not.Again.Interfaces;

namespace Not.Again.Database
{
public class TestAssemblyPutter : ITestAssemblyPutter
{
private const string UnknownTestRunner = "Unknown";

private readonly NotAgainDbContext _context;
private readonly ITestAssemblyGetter _testAssemblyGetter;

public TestAssemblyPutter(
NotAgainDbContext context,
ITestAssemblyGetter testAssemblyGetter)
{
_testAssemblyGetter = testAssemblyGetter;
_context = context;
}

public async Task<TestAssembly> AddOrUpdateTestAssemblyAsync(
string assemblyName,
string testRunner
)
{
testRunner = string.IsNullOrEmpty(testRunner) ? UnknownTestRunner : testRunner;

var testAssembly = new TestAssembly
{
TestAssemblyName = assemblyName,
TestRunner = testRunner
};

var dbTestAssembly =
await
_testAssemblyGetter
.GetAsync(testAssembly);

if (dbTestAssembly == null)
{
dbTestAssembly =
(await
_context
.TestAssembly
.AddAsync(testAssembly))
.Entity;

await
_context
.SaveChangesAsync();
}

return dbTestAssembly;
}
}
}
Loading

0 comments on commit 4b31e05

Please sign in to comment.