-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add copy constructor to
RequestConfiguration{Descriptor}
(#133)
- Loading branch information
Showing
3 changed files
with
148 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
tests/Elastic.Transport.Tests/Configuration/RequestConfigurationTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Licensed to Elasticsearch B.V under one or more agreements. | ||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information | ||
|
||
using System; | ||
using System.Security.Cryptography.X509Certificates; | ||
using System.Threading; | ||
using FluentAssertions; | ||
using Xunit; | ||
#if !NETFRAMEWORK | ||
using Soenneker.Utils.AutoBogus; | ||
#endif | ||
|
||
namespace Elastic.Transport.Tests.Configuration; | ||
|
||
public class RequestConfigurationTests | ||
{ | ||
[Fact] | ||
public void CopiesAllDefaults() | ||
{ | ||
var config = new RequestConfiguration(); | ||
var newConfig = new RequestConfiguration(config); | ||
|
||
config.Should().BeEquivalentTo(newConfig); | ||
} | ||
|
||
[Fact] | ||
public void SameDefaults() | ||
{ | ||
IRequestConfiguration config = new RequestConfiguration(); | ||
IRequestConfiguration newConfig = new RequestConfigurationDescriptor(); | ||
|
||
config.Should().BeEquivalentTo(newConfig); | ||
} | ||
|
||
#if !NETFRAMEWORK | ||
[Fact] | ||
public void CopiesAllProperties() | ||
{ | ||
var autoFaker = new AutoFaker<RequestConfiguration>(); | ||
autoFaker.RuleFor(x => x.ClientCertificates, f => new X509CertificateCollection()); | ||
|
||
var config = autoFaker.Generate(); | ||
config.Accept.Should().NotBeEmpty(); | ||
config.ClientCertificates.Should().NotBeNull(); | ||
|
||
IRequestConfiguration newConfig = new RequestConfiguration(config); | ||
config.Should().BeEquivalentTo(newConfig); | ||
|
||
IRequestConfiguration newDescriptor = new RequestConfigurationDescriptor(config); | ||
config.Should().BeEquivalentTo(newDescriptor); | ||
} | ||
#endif | ||
} |