Skip to content
Shared .NET libraries to do more with less code!
C#
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
samples/AspNetCoreApiSample
src Update to ASP.NET Core 3.1 and .NET Standard 2.1 (#13) Jan 26, 2020
test
.dockerignore Feature/add webapp lib (#4) Apr 7, 2019
.editorconfig
.gitattributes
.gitignore
CodeCoverage.runsettings
Directory.Build.props Update to ASP.NET Core 3.1 and .NET Standard 2.1 (#13) Jan 26, 2020
README.md
Withywoods.sln Feature/add basic rest test runner (#8) Oct 15, 2019

README.md

Devpro Withywoods - Shared .NET libraries

Build Status Quality Gate Status Coverage

Whithywoods is a set of small independant .NET libraries (Standard/Core). The goal is to do better with less code and capitalize on best practices (#KISS #DRY).

All libraries are available on nuget.org. Feel free to report any issue or ask for a change. You can also contribute with Pull Requests on GitHub!

NB: The name Whithywoods comes from Robin Hobb's incredible writing.

Getting started

Common

Configuration

Version Downloads

New extension method to access configuration: configuration.TryGetSection().

More information

Serialization

Version Downloads

Small extensions methods: myObject.ToJson() and myString.FromJson().

More information

Data Access Layer (DAL)

MongoDB DAL

Version Downloads

No need to dig into MongoDB driver documentation and experimentation, just use the provided RepositoryBase!

Configuration interface and dependency injection will help through defining only what is required and you have the choice to configure it the way you want (no forced section names in your configuration file).

More information.

Web

Selenium

Version Downloads

New extension method to find an element with a wait: driver.FindElement(By.ClassName("title"), 360);.

More information.

Web application

Version Downloads

Easily add Swagger self-generated web page, only two lines in your Startup class!

services.AddSwaggerGen(_webAppConfiguration); // in ConfigureServices()

app.UseSwagger(_webAppConfiguration); // in Configure()

More information.

Web testing

Version Downloads

Use Selenium web driver inside ASP.NET Integration tests? Yes, that's possible with LocalServerFactory class!

public class SwaggerResourceTest : IClassFixture<LocalServerFactory<Startup>>, IDisposable
{
    [Fact]
    public void AspNetCoreApiSampleSwaggerResourceGet_ReturnsHttpOk()
    {
        // Arrange & Act
        _webDriver.Navigate().GoToUrl($"{_server.RootUri}/{_ResourceEndpoint}");

        // Assert
        _webDriver.FindElement(By.ClassName("title"), 360);
        _webDriver.Title.Should().Be("Swagger UI");
        _webDriver.FindElementByClassName("title").Text.Should().Contain("My API");
    }
}

Want to write easy API Rest tests? Sure, just use the TestRunner class!

[Fact]
public async Task AspNetCoreApiSampleTaskResourceFullCycle_IsOk()
{
    var initialTasks = await _restRunner.GetResources<TaskDto>(_client);
    initialTasks.Count.Should().Be(0);

    var created = await _restRunner.CreateResource<TaskDto>(_client);

    await _restRunner.GetResourceById(created.Id, _client, created);

    await _restRunner.UpdateResource(created.Id, created, _client);

    var existingTasks = await _restRunner.GetResources<TaskDto>(_client);
    existingTasks.Count.Should().Be(1);

    await _restRunner.DeleteResource(created.Id, _client);

    var expectedNotFound = new ProblemDetails
    {
        Title = "Not Found",
        Status = 404,
        Type = "https://tools.ietf.org/html/rfc7231#section-6.5.4"
    };
    await _restRunner.GetResourceById(created.Id, _client, expectedNotFound, HttpStatusCode.NotFound, config => config.Excluding(x => x.Extensions));

    var finalTasks = await _restRunner.GetResources<TaskDto>(_client);
    finalTasks.Count.Should().Be(0);
}

More information.

Build & Debug

  • .NET Core SDK must be installed (download)
    • Check the version from the command line dotnet --version (>= 2.2.104)
  • Clone the repository (replace by the url if it was forked): git clone https://github.com/devpro/withywoods.git
  • Enter the directory: cd withywoods
  • Restore packages (NuGet): dotnet restore
  • Build the solution: dotnet run
  • Run the tests: dotnet test

Samples

AspNetCoreApiSample

This is a fully working example, with Swagger generation, API controllers, completely tested by integration tests.

You can’t perform that action at this time.