diff --git a/tests/FactSet.SDK.Utils.Tests/Authentication/ConfidentialClientTests.cs b/tests/FactSet.SDK.Utils.Tests/Authentication/ConfidentialClientTests.cs index c5c8d9b..5bf7e44 100644 --- a/tests/FactSet.SDK.Utils.Tests/Authentication/ConfidentialClientTests.cs +++ b/tests/FactSet.SDK.Utils.Tests/Authentication/ConfidentialClientTests.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.IO; using System.Net; using System.Net.Http; @@ -22,7 +21,8 @@ class ConfidentialClientTests [SetUp] public void Setup() { - _resourcesPath = Path.Join(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.ToString(), "Resources"); + _resourcesPath = Path.Join(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.ToString(), + "Resources"); _testHttpClientEmptyRes = CreateMockHttp(Path.Join(_resourcesPath, "emptyJson.json")); _testHttpClientValidRes = CreateMockHttp(Path.Join(_resourcesPath, "exampleResponseWellKnownUri.txt")); } @@ -36,7 +36,7 @@ public async Task CreateAsync_PassNullPath_ThrowsArgumentNullException() } catch (Exception e) { - Assert.AreEqual("Value cannot be null. (Parameter 'configPath')", e.Message); + Assert.That("Value cannot be null. (Parameter 'configPath')", Is.EqualTo(e.Message)); Assert.Throws(() => throw e); } } @@ -50,7 +50,7 @@ public async Task CreateAsync_PassingExplicitNull_ThrowsArgumentNullException() } catch (Exception e) { - Assert.AreEqual("Value cannot be null. (Parameter 'config')", e.Message); + Assert.That("Value cannot be null. (Parameter 'config')", Is.EqualTo(e.Message)); Assert.Throws(() => throw e); } } @@ -67,7 +67,7 @@ await ConfidentialClient.CreateAsync( } catch (Exception e) { - Assert.AreEqual("'clientId' cannot be null or empty.", e.Message); + Assert.That("'clientId' cannot be null or empty.", Is.EqualTo(e.Message)); Assert.Throws(() => throw e); } } @@ -103,7 +103,8 @@ await ConfidentialClient.CreateAsync( } catch (Exception e) { - Assert.AreEqual($"Exception caught when retrieving contents of {Path.Join(_resourcesPath, "badJson.txt")}", e.Message); + Assert.That($"Exception caught when retrieving contents of {Path.Join(_resourcesPath, "badJson.txt")}", + Is.EqualTo(e.Message)); Assert.Throws(() => throw e); } } @@ -120,7 +121,7 @@ await ConfidentialClient.CreateAsync( } catch (Exception e) { - Assert.AreEqual($"'clientId' cannot be null or empty.", e.Message); + Assert.That($"'clientId' cannot be null or empty.", Is.EqualTo(e.Message)); Assert.Throws(() => throw e); } } @@ -137,7 +138,7 @@ await ConfidentialClient.CreateAsync( } catch (Exception e) { - Assert.AreEqual($"'jwk' cannot be null.", e.Message); + Assert.That($"'jwk' cannot be null.", Is.EqualTo(e.Message)); Assert.Throws(() => throw e); } } @@ -154,7 +155,9 @@ await ConfidentialClient.CreateAsync( } catch (Exception e) { - Assert.AreEqual($"JWK must contain the following items: {string.Join(", ", Constants.CONFIG_JWK_REQUIRED_KEYS)}", e.Message); + Assert.That( + $"JWK must contain the following items: {string.Join(", ", Constants.CONFIG_JWK_REQUIRED_KEYS)}", + Is.EqualTo(e.Message)); Assert.Throws(() => throw e); } } @@ -171,7 +174,9 @@ await ConfidentialClient.CreateAsync( } catch (Exception e) { - Assert.AreEqual($"JWK must contain the following items: {string.Join(", ", Constants.CONFIG_JWK_REQUIRED_KEYS)}", e.Message); + Assert.That( + $"JWK must contain the following items: {string.Join(", ", Constants.CONFIG_JWK_REQUIRED_KEYS)}", + Is.EqualTo(e.Message)); Assert.Throws(() => throw e); } } @@ -203,7 +208,9 @@ await ConfidentialClient.CreateAsync( } catch (Exception e) { - Assert.AreEqual($"JWK must contain the following items: {string.Join(", ", Constants.CONFIG_JWK_REQUIRED_KEYS)}", e.Message); + Assert.That( + $"JWK must contain the following items: {string.Join(", ", Constants.CONFIG_JWK_REQUIRED_KEYS)}", + Is.EqualTo(e.Message)); Assert.Throws(() => throw e); } } @@ -220,7 +227,7 @@ await ConfidentialClient.CreateAsync( } catch (Exception e) { - Assert.AreEqual($"'clientId' cannot be null or empty.", e.Message); + Assert.That($"'clientId' cannot be null or empty.", Is.EqualTo(e.Message)); Assert.Throws(() => throw e); } } @@ -248,8 +255,9 @@ await ConfidentialClient.CreateAsync( } catch (Exception e) { - Assert.AreEqual($"Error retrieving contents from the well_known_uri: {Constants.FACTSET_WELL_KNOWN_URI}", e.Message); - Assert.IsInstanceOf(e); + Assert.That($"Error retrieving contents from the well_known_uri: {Constants.FACTSET_WELL_KNOWN_URI}", + Is.EqualTo(e.Message)); + Assert.That(e, Is.InstanceOf()); } } @@ -279,7 +287,7 @@ public async Task CreateAsync_PassingValidConfigPathValidConfigJSON_InitialisesW httpClient: _testHttpClientValidRes ); - Assert.IsInstanceOf(confidentialClient); + Assert.That(confidentialClient, Is.InstanceOf()); } catch (Exception) { @@ -288,22 +296,24 @@ public async Task CreateAsync_PassingValidConfigPathValidConfigJSON_InitialisesW } [Test] - public async Task CreateAsync_InitialiseAndCastConfidentialClientToIOAuth2Client_InitialisesAndCastsSuccessfully() + public async Task + CreateAsync_InitialiseAndCastConfidentialClientToIOAuth2Client_InitialisesAndCastsSuccessfully() { ConfidentialClient confidentialClient = await ConfidentialClient.CreateAsync( Path.Join(_resourcesPath, "validConfig.json"), httpClient: _testHttpClientValidRes ); - Assert.IsInstanceOf(confidentialClient); - Assert.IsInstanceOf((IOAuth2Client)confidentialClient); + Assert.That(confidentialClient, Is.InstanceOf()); + Assert.That((IOAuth2Client)confidentialClient, Is.InstanceOf()); } [Test] public async Task GetAccessTokenAsync_CallingGetAccessTokenWithFailedSigning_RaisesSigningJwsException() { int expireTime = 100; - HttpClient mockClient = CreateMockHttpTokenRequest(Path.Join(_resourcesPath, "exampleResponseWellKnownUri.txt"), expireTime); + HttpClient mockClient = + CreateMockHttpTokenRequest(Path.Join(_resourcesPath, "exampleResponseWellKnownUri.txt"), expireTime); // validConfig.txt is a valid config format, but invalid for signing a JWT. ConfidentialClient confidentialClient = await ConfidentialClient.CreateAsync( @@ -317,7 +327,7 @@ public async Task GetAccessTokenAsync_CallingGetAccessTokenWithFailedSigning_Rai } catch (Exception e) { - Assert.AreEqual($"Failed signing of the JWS", e.Message); + Assert.That($"Failed signing of the JWS", Is.EqualTo(e.Message)); Assert.Throws(() => throw e); } } @@ -325,7 +335,8 @@ public async Task GetAccessTokenAsync_CallingGetAccessTokenWithFailedSigning_Rai [Test] public async Task GetAccessTokenAsync_CallingGetAccessTokenWithErrorResponse_RaisesAccessTokenException() { - HttpClient mockClient = CreateErroneousMockHttpTokenRequest(Path.Join(_resourcesPath, "exampleResponseWellKnownUri.txt")); + HttpClient mockClient = + CreateErroneousMockHttpTokenRequest(Path.Join(_resourcesPath, "exampleResponseWellKnownUri.txt")); // validConfig.txt is a valid config format, but invalid for signing a JWT. ConfidentialClient confidentialClient = await ConfidentialClient.CreateAsync( @@ -339,7 +350,7 @@ public async Task GetAccessTokenAsync_CallingGetAccessTokenWithErrorResponse_Rai } catch (Exception e) { - Assert.AreEqual($"Error attempting to get access token", e.Message); + Assert.That($"Error attempting to get access token", Is.EqualTo(e.Message)); Assert.Throws(() => throw e); } } @@ -348,7 +359,8 @@ public async Task GetAccessTokenAsync_CallingGetAccessTokenWithErrorResponse_Rai public async Task GetAccessTokenAsync_CallingGetAccessTokenForTheFirstTime_ReturnsNewAccessToken() { int expireTime = 100; - HttpClient mockClient = CreateMockHttpTokenRequest(Path.Join(_resourcesPath, "exampleResponseWellKnownUri.txt"), expireTime); + HttpClient mockClient = + CreateMockHttpTokenRequest(Path.Join(_resourcesPath, "exampleResponseWellKnownUri.txt"), expireTime); ConfidentialClient confidentialClient = await ConfidentialClient.CreateAsync( Path.Join(_resourcesPath, "validConfigGeneratedSample.txt"), @@ -357,14 +369,15 @@ public async Task GetAccessTokenAsync_CallingGetAccessTokenForTheFirstTime_Retur string accessToken = await confidentialClient.GetAccessTokenAsync(); - Assert.AreEqual("1234", accessToken); + Assert.That("1234", Is.EqualTo(accessToken)); } [Test] public async Task GetAccessTokenAsync_CallingGetAccessTokenTwiceBeforeExpiration_ReturnsSameAccessToken() { int expireTime = 100; - HttpClient mockClient = CreateMockHttpTokenRequest(Path.Join(_resourcesPath, "exampleResponseWellKnownUri.txt"), expireTime); + HttpClient mockClient = + CreateMockHttpTokenRequest(Path.Join(_resourcesPath, "exampleResponseWellKnownUri.txt"), expireTime); ConfidentialClient confidentialClient = await ConfidentialClient.CreateAsync( Path.Join(_resourcesPath, "validConfigGeneratedSample.txt"), @@ -373,19 +386,21 @@ public async Task GetAccessTokenAsync_CallingGetAccessTokenTwiceBeforeExpiration string accessToken = await confidentialClient.GetAccessTokenAsync(); - Assert.AreEqual("1234", accessToken); + Assert.That("1234", Is.EqualTo(accessToken)); // Called immediately after the first `GetAccessToken` call, so its within expiration. accessToken = await confidentialClient.GetAccessTokenAsync(); - Assert.AreEqual("1234", accessToken); + Assert.That("1234", Is.EqualTo(accessToken)); } [Test] - public async Task GetAccessTokenAsync_CallingGetAccessTokenBeforeAndAfterExpiration_ReturnsDifferentAccessTokens() + public async Task + GetAccessTokenAsync_CallingGetAccessTokenBeforeAndAfterExpiration_ReturnsDifferentAccessTokens() { int expireTime = 0; - HttpClient mockClient = CreateMockHttpTokenRequest(Path.Join(_resourcesPath, "exampleResponseWellKnownUri.txt"), expireTime); + HttpClient mockClient = + CreateMockHttpTokenRequest(Path.Join(_resourcesPath, "exampleResponseWellKnownUri.txt"), expireTime); ConfidentialClient confidentialClient = await ConfidentialClient.CreateAsync( Path.Join(_resourcesPath, "validConfigGeneratedSample.txt"), @@ -394,12 +409,12 @@ public async Task GetAccessTokenAsync_CallingGetAccessTokenBeforeAndAfterExpirat string accessToken = await confidentialClient.GetAccessTokenAsync(); - Assert.AreEqual("1234", accessToken); + Assert.That("1234", Is.EqualTo(accessToken)); // Called after a zero expiration. accessToken = await confidentialClient.GetAccessTokenAsync(); - Assert.AreEqual("4321", accessToken); + Assert.That("4321", Is.EqualTo(accessToken)); } [Test] @@ -441,8 +456,8 @@ public async Task GetAccessTokenAsync_CallingGetAccessTokenWithFailedResponse_Th } catch (Exception e) { - Assert.IsInstanceOf(e); - Assert.AreEqual($"Error attempting to get access token", e.Message); + Assert.That(e, Is.InstanceOf()); + Assert.That($"Error attempting to get access token", Is.EqualTo(e.Message)); } } @@ -509,12 +524,14 @@ private static HttpClient CreateMockHttpTokenRequest(string wellKnownUriPath, in .ReturnsAsync(new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, - Content = new StringContent($"{{\"access_token\":\"1234\",\"token_type\":\"Bearer\",\"expires_in\":\"{expireTime}\"}}") + Content = new StringContent( + $"{{\"access_token\":\"1234\",\"token_type\":\"Bearer\",\"expires_in\":\"{expireTime}\"}}") }) .ReturnsAsync(new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, - Content = new StringContent($"{{\"access_token\":\"4321\",\"token_type\":\"Bearer\",\"expires_in\":\"{expireTime}\"}}") + Content = new StringContent( + $"{{\"access_token\":\"4321\",\"token_type\":\"Bearer\",\"expires_in\":\"{expireTime}\"}}") }); mockHandler @@ -552,4 +569,3 @@ private static string GetJsonFromFile(string path) } } } - diff --git a/tests/FactSet.SDK.Utils.Tests/Authentication/ConfigurationTests.cs b/tests/FactSet.SDK.Utils.Tests/Authentication/ConfigurationTests.cs index 718c77c..7f08233 100644 --- a/tests/FactSet.SDK.Utils.Tests/Authentication/ConfigurationTests.cs +++ b/tests/FactSet.SDK.Utils.Tests/Authentication/ConfigurationTests.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.IO; using FactSet.SDK.Utils.Authentication; using Microsoft.IdentityModel.Tokens; @@ -16,7 +15,8 @@ class ConfigurationTests [SetUp] public void Setup() { - _resourcesPath = Path.Join(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.ToString(), "Resources"); + _resourcesPath = Path.Join(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.ToString(), + "Resources"); _validJwk = @" { @@ -54,24 +54,24 @@ public void Setup() public void Configuration_PassingEverythingNull_ThrowsArgumentException() { Assert.Throws(() => new Configuration(clientId: null, - clientAuthType: null, - jwk: null)); + clientAuthType: null, + jwk: null)); } [Test] public void Configuration_PassingClientIdNull_ThrowsArgumentException() { Assert.Throws(() => new Configuration(clientId: null, - clientAuthType: "test", - jwk: new JsonWebKey(_validJwk))); + clientAuthType: "test", + jwk: new JsonWebKey(_validJwk))); } [Test] public void Configuration_PassingClientAuthTypeNull_ThrowsArgumentException() { Assert.Throws(() => new Configuration(clientId: "test", - clientAuthType: null, - jwk: new JsonWebKey(_validJwk))); + clientAuthType: null, + jwk: new JsonWebKey(_validJwk))); } [Test] @@ -79,32 +79,32 @@ public void Configuration_PassingJwkNull_ThrowsArgumentException() { JsonWebKey jsonWebKey = null; Assert.Throws(() => new Configuration(clientId: "test", - clientAuthType: "test", - jwk: jsonWebKey)); + clientAuthType: "test", + jwk: jsonWebKey)); } [Test] public void Configuration_PassingEmptyAndNull_ThrowsArgumentException() { Assert.Throws(() => new Configuration(clientId: "", - clientAuthType: "", - jwk: null)); + clientAuthType: "", + jwk: null)); } [Test] public void Configuration_PassingClientIdEmpty_ThrowsArgumentException() { Assert.Throws(() => new Configuration(clientId: "", - clientAuthType: "test", - jwk: new JsonWebKey(_validJwk))); + clientAuthType: "test", + jwk: new JsonWebKey(_validJwk))); } [Test] public void Configuration_PassingClientAuthTypeEmpty_ThrowsArgumentException() { Assert.Throws(() => new Configuration(clientId: "test", - clientAuthType: "", - jwk: new JsonWebKey(_validJwk))); + clientAuthType: "", + jwk: new JsonWebKey(_validJwk))); } [Test] @@ -112,8 +112,8 @@ public void Configuration_PassingInvalidJwkMissingKty_ThrowsConfigurationExcepti { JsonWebKey jsonWebKey = new(_invalidJwkMissingKty); Assert.Throws(() => new Configuration(clientId: "test", - clientAuthType: "test", - jwk: jsonWebKey)); + clientAuthType: "test", + jwk: jsonWebKey)); } [Test] @@ -121,17 +121,16 @@ public void Configuration_PassingMissingJwk_ThrowsConfigurationException() { JsonWebKey jsonWebKey = new("{}"); Assert.Throws(() => new Configuration(clientId: "test", - clientAuthType: "test", - jwk: jsonWebKey)); + clientAuthType: "test", + jwk: jsonWebKey)); } [Test] public void Configuration_PassingValidConfig_InstantiatesConfiguration() { JsonWebKey jsonWebKey = new(_validJwk); - Assert.IsInstanceOf(new Configuration(clientId: "test", - clientAuthType: "test", - jwk: jsonWebKey)); + Assert.That(new Configuration(clientId: "test", clientAuthType: "test", jwk: jsonWebKey), + Is.InstanceOf()); } [Test] @@ -143,7 +142,7 @@ public void Parse_PassingNullConfigPath_ThrowsConfigurationException() } catch (Exception e) { - Assert.AreEqual("Value cannot be null. (Parameter 'configPath')", e.Message); + Assert.That("Value cannot be null. (Parameter 'configPath')", Is.EqualTo(e.Message)); Assert.Throws(() => throw e); } } @@ -151,7 +150,8 @@ public void Parse_PassingNullConfigPath_ThrowsConfigurationException() [Test] public void Parse_PassingNonExistingFilePath_ThrowsFileNotFoundException() { - Assert.Throws(() => Configuration.Parse(Path.Join(_resourcesPath, "somemoretests.txt"))); + Assert.Throws(() => + Configuration.Parse(Path.Join(_resourcesPath, "somemoretests.txt"))); } [Test] @@ -163,7 +163,9 @@ public void Parse_PassingConfigFileWithMissingJwkProperties_ThrowsConfigurationE } catch (Exception e) { - Assert.AreEqual($"JWK must contain the following items: {string.Join(", ", Constants.CONFIG_JWK_REQUIRED_KEYS)}", e.Message); + Assert.That( + $"JWK must contain the following items: {string.Join(", ", Constants.CONFIG_JWK_REQUIRED_KEYS)}", + Is.EqualTo(e.Message)); Assert.Throws(() => throw e); } } @@ -177,7 +179,7 @@ public void Parse_PassingConfigFileWithEmptyStringProperties_ThrowsArgumentExcep } catch (Exception e) { - Assert.AreEqual($"'clientId' cannot be null or empty.", e.Message); + Assert.That($"'clientId' cannot be null or empty.", Is.EqualTo(e.Message)); Assert.Throws(() => throw e); } } @@ -187,26 +189,26 @@ public void Parse_PassingCorrectConfigFileFormat_ReturnsConfigurationInstance() { Configuration config = Configuration.Parse(Path.Join(_resourcesPath, "validConfig.json")); - Assert.IsInstanceOf(config); + Assert.That(config, Is.InstanceOf()); // Non-Jwk config properties. - Assert.AreEqual("testClientId", config.ClientId); - Assert.AreEqual("testClientAuthType", config.ClientAuthType); - Assert.AreEqual(Constants.FACTSET_WELL_KNOWN_URI, config.WellKnownUri); + Assert.That("testClientId", Is.EqualTo(config.ClientId)); + Assert.That("testClientAuthType", Is.EqualTo(config.ClientAuthType)); + Assert.That(Constants.FACTSET_WELL_KNOWN_URI, Is.EqualTo(config.WellKnownUri)); // Jwk properties. - Assert.AreEqual("testKty", config.Jwk.Kty); - Assert.AreEqual("testUse", config.Jwk.Use); - Assert.AreEqual("testAlg", config.Jwk.Alg); - Assert.AreEqual("testKid", config.Jwk.Kid); - Assert.AreEqual("testD", config.Jwk.D); - Assert.AreEqual("testN", config.Jwk.N); - Assert.AreEqual("AQAB", config.Jwk.E); - Assert.AreEqual("testP", config.Jwk.P); - Assert.AreEqual("testQ", config.Jwk.Q); - Assert.AreEqual("testDP", config.Jwk.DP); - Assert.AreEqual("testDQ", config.Jwk.DQ); - Assert.AreEqual("testQI", config.Jwk.QI); + Assert.That("testKty", Is.EqualTo(config.Jwk.Kty)); + Assert.That("testUse", Is.EqualTo(config.Jwk.Use)); + Assert.That("testAlg", Is.EqualTo(config.Jwk.Alg)); + Assert.That("testKid", Is.EqualTo(config.Jwk.Kid)); + Assert.That("testD", Is.EqualTo(config.Jwk.D)); + Assert.That("testN", Is.EqualTo(config.Jwk.N)); + Assert.That("AQAB", Is.EqualTo(config.Jwk.E)); + Assert.That("testP", Is.EqualTo(config.Jwk.P)); + Assert.That("testQ", Is.EqualTo(config.Jwk.Q)); + Assert.That("testDP", Is.EqualTo(config.Jwk.DP)); + Assert.That("testDQ", Is.EqualTo(config.Jwk.DQ)); + Assert.That("testQI", Is.EqualTo(config.Jwk.QI)); } } } diff --git a/tests/FactSet.SDK.Utils.Tests/Authentication/ExceptionsTests.cs b/tests/FactSet.SDK.Utils.Tests/Authentication/ExceptionsTests.cs index cf417a6..a1d8a89 100644 --- a/tests/FactSet.SDK.Utils.Tests/Authentication/ExceptionsTests.cs +++ b/tests/FactSet.SDK.Utils.Tests/Authentication/ExceptionsTests.cs @@ -1,5 +1,4 @@ -using System.Runtime.Serialization; -using FactSet.SDK.Utils.Authentication; +using FactSet.SDK.Utils.Authentication; using NUnit.Framework; namespace FactSet.SDK.Utils.Tests.Authentication @@ -10,15 +9,15 @@ class ExceptionsTests public void AccessTokenException_EmptyArg_InitialisesWithBaseMessage() { var exception = new AccessTokenException(); - Assert.AreEqual("Exception of type 'FactSet.SDK.Utils.Authentication.AccessTokenException' was thrown.", - exception.Message); + Assert.That("Exception of type 'FactSet.SDK.Utils.Authentication.AccessTokenException' was thrown.", + Is.EqualTo(exception.Message)); } [Test] public void AccessTokenException_MessageArg_InitialisesWithCustomMessage() { var exception = new AccessTokenException("Test AccessTokenException message"); - Assert.AreEqual("Test AccessTokenException message", exception.Message); + Assert.That("Test AccessTokenException message", Is.EqualTo(exception.Message)); } [Test] @@ -26,23 +25,23 @@ public void AccessTokenException_MessageArgAndInnerException_InitialisesWithCust { var exception1 = new AccessTokenException("parent"); var exception2 = new AccessTokenException("Test AccessTokenException message", exception1); - Assert.AreEqual("Test AccessTokenException message", exception2.Message); - Assert.AreEqual(exception1, exception2.InnerException); + Assert.That("Test AccessTokenException message", Is.EqualTo(exception2.Message)); + Assert.That(exception1, Is.EqualTo(exception2.InnerException)); } [Test] public void ConfigurationException_EmptyArg_InitialisesWithBaseMessage() { var exception = new ConfigurationException(); - Assert.AreEqual("Exception of type 'FactSet.SDK.Utils.Authentication.ConfigurationException' was thrown.", - exception.Message); + Assert.That("Exception of type 'FactSet.SDK.Utils.Authentication.ConfigurationException' was thrown.", + Is.EqualTo(exception.Message)); } [Test] public void ConfigurationException_MessageArg_InitialisesWithCustomMessage() { var exception = new ConfigurationException("Test CredentialsException message"); - Assert.AreEqual("Test CredentialsException message", exception.Message); + Assert.That("Test CredentialsException message", Is.EqualTo(exception.Message)); } [Test] @@ -50,23 +49,23 @@ public void ConfigurationException_MessageArgAndInnerException_InitialisesWithCu { var exception1 = new ConfigurationException("parent"); var exception2 = new ConfigurationException("Test CredentialsException message", exception1); - Assert.AreEqual("Test CredentialsException message", exception2.Message); - Assert.AreEqual(exception1, exception2.InnerException); + Assert.That("Test CredentialsException message", Is.EqualTo(exception2.Message)); + Assert.That(exception1, Is.EqualTo(exception2.InnerException)); } [Test] public void WellKnownUriException_EmptyArg_InitialisesWithBaseMessage() { var exception = new WellKnownUriException(); - Assert.AreEqual("Exception of type 'FactSet.SDK.Utils.Authentication.WellKnownUriException' was thrown.", - exception.Message); + Assert.That("Exception of type 'FactSet.SDK.Utils.Authentication.WellKnownUriException' was thrown.", + Is.EqualTo(exception.Message)); } [Test] public void WellKnownUriException_MessageArg_InitialisesWithCustomMessage() { var exception = new WellKnownUriException("Test WellKnownUriException message"); - Assert.AreEqual("Test WellKnownUriException message", exception.Message); + Assert.That("Test WellKnownUriException message", Is.EqualTo(exception.Message)); } [Test] @@ -74,47 +73,48 @@ public void WellKnownUriException_MessageArgAndInnerException_InitialisesWithCus { var exception1 = new WellKnownUriException("parent"); var exception2 = new WellKnownUriException("Test WellKnownUriException message", exception1); - Assert.AreEqual("Test WellKnownUriException message", exception2.Message); - Assert.AreEqual(exception1, exception2.InnerException); + Assert.That("Test WellKnownUriException message", Is.EqualTo(exception2.Message)); + Assert.That(exception1, Is.EqualTo(exception2.InnerException)); } [Test] public void WellKnownUriContentException_EmptyArg_InitialisesWithBaseMessage() { var exception = new WellKnownUriContentException(); - Assert.AreEqual("Exception of type 'FactSet.SDK.Utils.Authentication.WellKnownUriContentException' was thrown.", - exception.Message); + Assert.That("Exception of type 'FactSet.SDK.Utils.Authentication.WellKnownUriContentException' was thrown.", + Is.EqualTo(exception.Message)); } [Test] public void WellKnownUriContentException_MessageArg_InitialisesWithCustomMessage() { var exception = new WellKnownUriContentException("Test WellKnownUriContentException message"); - Assert.AreEqual("Test WellKnownUriContentException message", exception.Message); + Assert.That("Test WellKnownUriContentException message", Is.EqualTo(exception.Message)); } [Test] - public void WellKnownUriContentException_MessageArgAndInnerException_InitialisesWithCustomMessageAndInnerException() + public void + WellKnownUriContentException_MessageArgAndInnerException_InitialisesWithCustomMessageAndInnerException() { var exception1 = new WellKnownUriContentException("parent"); var exception2 = new WellKnownUriContentException("Test WellKnownUriContentException message", exception1); - Assert.AreEqual("Test WellKnownUriContentException message", exception2.Message); - Assert.AreEqual(exception1, exception2.InnerException); + Assert.That("Test WellKnownUriContentException message", Is.EqualTo(exception2.Message)); + Assert.That(exception1, Is.EqualTo(exception2.InnerException)); } [Test] public void SigningJwsException_EmptyArg_InitialisesWithBaseMessage() { var exception = new SigningJwsException(); - Assert.AreEqual("Exception of type 'FactSet.SDK.Utils.Authentication.SigningJwsException' was thrown.", - exception.Message); + Assert.That("Exception of type 'FactSet.SDK.Utils.Authentication.SigningJwsException' was thrown.", + Is.EqualTo(exception.Message)); } [Test] public void SigningJwsException_MessageArg_InitialisesWithCustomMessage() { var exception = new SigningJwsException("Test SigningJwsException message"); - Assert.AreEqual("Test SigningJwsException message", exception.Message); + Assert.That("Test SigningJwsException message", Is.EqualTo(exception.Message)); } [Test] @@ -122,8 +122,8 @@ public void SigningJwsException_MessageArgAndInnerException_InitialisesWithCusto { var exception1 = new SigningJwsException("parent"); var exception2 = new SigningJwsException("Test SigningJwsException message", exception1); - Assert.AreEqual("Test SigningJwsException message", exception2.Message); - Assert.AreEqual(exception1, exception2.InnerException); + Assert.That("Test SigningJwsException message", Is.EqualTo(exception2.Message)); + Assert.That(exception1, Is.EqualTo(exception2.InnerException)); } } } diff --git a/tests/FactSet.SDK.Utils.Tests/Authentication/OAuth2ClientTests.cs b/tests/FactSet.SDK.Utils.Tests/Authentication/OAuth2ClientTests.cs index 1ce5b75..6012ec3 100644 --- a/tests/FactSet.SDK.Utils.Tests/Authentication/OAuth2ClientTests.cs +++ b/tests/FactSet.SDK.Utils.Tests/Authentication/OAuth2ClientTests.cs @@ -10,7 +10,7 @@ class OAuth2ClientTests public void OAuth2ClientGoodInstantiation() { OAuth2ClientCorrect oAuth = new OAuth2ClientCorrect(); - Assert.IsInstanceOf(oAuth); + Assert.That(oAuth, Is.InstanceOf()); } } diff --git a/tests/FactSet.SDK.Utils.Tests/FactSet.SDK.Utils.Tests.csproj b/tests/FactSet.SDK.Utils.Tests/FactSet.SDK.Utils.Tests.csproj index 1175d46..409b957 100644 --- a/tests/FactSet.SDK.Utils.Tests/FactSet.SDK.Utils.Tests.csproj +++ b/tests/FactSet.SDK.Utils.Tests/FactSet.SDK.Utils.Tests.csproj @@ -9,7 +9,7 @@ - +