Skip to content

Commit

Permalink
chore: update to .net8 / marten 7 / NUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexZeitler committed Apr 14, 2024
1 parent 974866b commit 67729ae
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 43 deletions.

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
@@ -1,23 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<IsPackable>false</IsPackable>

<LangVersion>12</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Marten" Version="6.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="xunit" Version="2.6.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
<PackageReference Include="IDisposableAnalyzers" Version="4.0.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PackageReference Include="Marten" Version="7.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
3 changes: 2 additions & 1 deletion src/MartenDotNetTestTemplate.Tests/Usings.cs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
global using Xunit;
global using NUnit.Framework;
global using Shouldly;
Original file line number Diff line number Diff line change
@@ -1,48 +1,43 @@
using Marten;
using Marten.Events.Aggregation;
using Marten.Events.Projections;
using Newtonsoft.Json;
using Shouldly;
using static MartenDotNetTestTemplate.Tests.TestDatabase;

namespace MartenDotNetTestTemplate.Tests;

public record SomethingHappened(DateTimeOffset On);

public class Something
public record Something(DateTimeOffset On)
{
public Guid Id { get; set; }
public DateTimeOffset On { get; }
};

[JsonConstructor]
private Something()
{
}

private Something(DateTimeOffset on)
{
On = on;
}

public static Something Create(SomethingHappened happened)
{
return new Something(happened.On);
}
public class SomethingProjection : SingleStreamProjection<Something>
{
public static Something Create(
SomethingHappened happened
) =>
new(happened.On);
}

[TestFixture]
public class When_snapshot_is_configured_inline
{
public class When_event_is_persisted : IAsyncLifetime
public class When_event_is_persisted
{
private Guid _streamId;
private DocumentStore? _store;

[SetUp]
public async Task InitializeAsync()
{
_store = DocumentStore.For(_ =>
{
_.Connection(GetTestDbConnectionString);
_.Projections.Snapshot<Something>(SnapshotLifecycle.Inline);
});
_store = DocumentStore.For(
_ =>
{
_.Connection(GetTestDbConnectionString());
_.Projections.Add<SomethingProjection>(ProjectionLifecycle.Inline);
}
);

var on = DateTimeOffset.Now;
var happened = new SomethingHappened(on);
Expand All @@ -53,19 +48,16 @@ public async Task InitializeAsync()
await session.SaveChangesAsync();
}

[Fact]
[Test]
public async Task should_write_snapshot_in_same_transaction()
{
await using var session = _store.QuerySession();
var something = session.Load<Something>(_streamId);
await using var session = _store?.QuerySession();
var something = await session?.LoadAsync<Something>(_streamId)!;
something.ShouldNotBeNull();
}


public Task DisposeAsync()
{
_store.Dispose();
return Task.CompletedTask;
}
[TearDown]
public async Task DisposeAsync() => await _store.DisposeAsync();
}
}
2 changes: 1 addition & 1 deletion src/global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.0",
"version": "8.0.0",
"rollForward": "latestMinor",
"allowPrerelease": true
}
Expand Down

0 comments on commit 67729ae

Please sign in to comment.