Skip to content

Commit

Permalink
Check all StorageProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdotnet committed Jul 14, 2021
1 parent a491137 commit fc9ef0c
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using FluentAssertions;
using LinkDotNet.Blog.Web.RegistrationExtensions;
using Microsoft.Extensions.DependencyInjection;
Expand All @@ -8,15 +9,24 @@ namespace LinkDotNet.Blog.UnitTests
{
public class StorageProviderRegistrationExtensionsTests
{
[Fact]
public void GivenAlreadyRegisteredRepository_WhenTryingToAddAnotherOne_ThenException()
public static IEnumerable<object[]> Data => new List<object[]>
{
new object[] { new Action<IServiceCollection>(services => services.UseSqliteAsStorageProvider()) },
new object[] { new Action<IServiceCollection>(services => services.UseSqlAsStorageProvider()) },
new object[] { new Action<IServiceCollection>(services => services.UseInMemoryAsStorageProvider()) },
new object[] { new Action<IServiceCollection>(services => services.UseRavenDbAsStorageProvider()) },
};

[Theory]
[MemberData(nameof(Data))]
public void GivenAlreadyRegisteredRepository_WhenTryingToAddAnotherStorage_ThenException(Action<IServiceCollection> act)
{
var services = new ServiceCollection();
services.UseRavenDbAsStorageProvider();

Action act = () => services.UseSqliteAsStorageProvider();
Action actualAct = () => act(services);

act.Should().Throw<NotSupportedException>();
actualAct.Should().Throw<NotSupportedException>();
}
}
}

0 comments on commit fc9ef0c

Please sign in to comment.