Example #1
0
    public async Task ValidateRequest_Default_Success()
    {
        string location  = Guid.NewGuid().ToString();
        string name      = Guid.NewGuid().ToString();
        string libraryId = Guid.NewGuid().ToString();
        string tenantId  = Guid.NewGuid().ToString();

        var           mockHttp = new MockHttpMessageHandler();
        MockedRequest request  = mockHttp
                                 .When(HttpMethod.Get, "*/libraries")
                                 .Respond("application/json", $"[{{'libraryId': '{libraryId}', 'tenantId': '{tenantId}', 'name': '{name}', 'location': '{location}'}}]");

        IServiceProvider       services     = ConfigureServices(mockHttp);
        IDocumentLibraryClient docLibClient = services.GetRequiredService <IDocumentLibraryClient>();

        ICollection <Library> libraries = await docLibClient.ListLibrariesAsync().ConfigureAwait(false);

        mockHttp.GetMatchCount(request).Should().Be(1);

        libraries.Should().NotBeNullOrEmpty();
        libraries.Should().HaveCount(1);

        Library library = libraries.Single();

        library.Should().NotBeNull();
        library.TenantId.Should().Be(tenantId);
        library.Name.Should().Be(name);
    }