Skip to content

Commit

Permalink
[WIP]
Browse files Browse the repository at this point in the history
Other changes
- Remove unnecessary constraint on generic type parameter
  • Loading branch information
gyuwon committed May 6, 2019
1 parent 0ba6436 commit 3bac4b9
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 10 deletions.
24 changes: 24 additions & 0 deletions source/Loom.EventSourcing.Azure/BlobSnapshotter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace Loom.EventSourcing.Azure
{
using System;
using System.Threading.Tasks;
using Microsoft.Azure.Storage.Blob;

public class BlobSnapshotter<T> : ISnapshotter
{
private readonly IStateRehydrator<T> _rehydrator;
private readonly CloudBlobContainer _container;

public BlobSnapshotter(
IStateRehydrator<T> rehydrator, CloudBlobContainer container)
{
_rehydrator = rehydrator;
_container = container;
}

public Task TakeSnapshot(Guid streamId)
{
return Task.CompletedTask;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Cosmos.Table" Version="1.0.1" />
<PackageReference Include="Microsoft.Azure.Storage.Blob" Version="10.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion source/Loom.EventSourcing/IStateRehydrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Threading.Tasks;

public interface IStateRehydrator<T>
where T : IVersioned
{
// TODO: Change return type to Task<T?>.
Task<T> TryRehydrateState(Guid streamId);
Expand Down
32 changes: 32 additions & 0 deletions source/Loom.Tests/EventSourcing/Azure/BlobSnapshotter_specs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace Loom.EventSourcing.Azure
{
using System;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
public class BlobSnapshotter_specs
{
public class State
{
public State(int value1, string value2, Guid value3)
{
Value1 = value1;
Value2 = value2;
Value3 = value3;
}

public int Value1 { get; }

public string Value2 { get; }

public Guid Value3 { get; }
}

[TestMethod]
public void sut_implements_ISnapshotter()
{
typeof(BlobSnapshotter<State>).Should().Implement<ISnapshotter>();
}
}
}
27 changes: 18 additions & 9 deletions source/Loom.Tests/EventSourcing/Azure/StorageEmulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,31 @@
{
using System.Threading.Tasks;
using Microsoft.Azure.Cosmos.Table;
using Microsoft.Azure.Storage.Blob;

public static class StorageEmulator
{
public static string EventStoreName => "UnitTestingEventStore";

public static CloudTable EventStoreTable { get; } = CloudStorageAccount
.DevelopmentStorageAccount
.CreateCloudTableClient()
.GetTableReference(EventStoreName);
public static string SnapshotContainerName => "unit-testing-snapshot-store";

public static CloudBlobContainer SnapshotContainer { get; } =
Microsoft.Azure.Storage.CloudStorageAccount
.DevelopmentStorageAccount
.CreateCloudBlobClient()
.GetContainerReference(SnapshotContainerName);

public static async Task Initialize()
{
await EventStoreTable.DeleteIfExistsAsync();
await EventStoreTable.CreateAsync();
}

public static CloudStorageAccount StorageAccount
=> CloudStorageAccount.DevelopmentStorageAccount;

public static string EventStoreName => "UnitTestingEventStore";

public static CloudTable EventStoreTable { get; } = StorageAccount
.CreateCloudTableClient()
.GetTableReference(EventStoreName);
await SnapshotContainer.DeleteIfExistsAsync();
await SnapshotContainer.CreateAsync();
}
}
}

0 comments on commit 3bac4b9

Please sign in to comment.