Skip to content

Instantly share code, notes, and snippets.

@eramax
Created October 26, 2021 18:37
Show Gist options
  • Save eramax/ee6e6bbe50db44425b2bafe54a0bbd73 to your computer and use it in GitHub Desktop.
Save eramax/ee6e6bbe50db44425b2bafe54a0bbd73 to your computer and use it in GitHub Desktop.
NetArchTests
using NetArchTest.Rules;
using WebApi2.Services;
using Xunit;
/// <summary>
/// NetArchTest
/// https://github.com/BenMorris/NetArchTest
/// </summary>
namespace NetArch
{
public class directly_reference
{
[Fact]
public void Classes_in_presentation_should_not_directly_reference_repositories()
{
// Classes in the presentation should not directly reference repositories
var result = Types.InCurrentDomain()
.That()
.ResideInNamespace("WebApi2.Controllers")
.ShouldNot()
.HaveDependencyOn("DataLib")
.GetResult()
.IsSuccessful;
}
[Fact]
public void All_the_service_classes_should_be_sealed()
{
// All the service classes should be sealed
var result = Types.InCurrentDomain()
.That().ImplementInterface(typeof(IUserService))
.Should().BeSealed()
.GetResult()
.IsSuccessful;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment