From e7541e99a7c125f29d30c1454d463df65d6eab98 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 22 Aug 2017 15:25:22 -0700 Subject: [PATCH] Upgrade to xunit 2.3.0-beta4 --- build/dependencies.props | 4 ++-- .../CertificateLoaderTests.cs | 24 +++++++++---------- .../HostingApplicationTests.cs | 2 +- .../Internal/HostingEventSourceTests.cs | 4 ++-- .../StartupManagerTests.cs | 10 ++++---- .../WebHostBuilderTests.cs | 6 ++--- .../WebHostTests.cs | 2 +- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 3717887177..14f76f769d 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -6,9 +6,9 @@ 2.0.0-* 2.0.0-* 2.0.0-* - 15.3.0-* + 15.3.0 1.0.1 - 2.3.0-beta2-* + 2.3.0-beta4-build3742 4.7.49 1.4.0 3.2.0 diff --git a/test/Microsoft.AspNetCore.Certificates.Configuration.Tests/CertificateLoaderTests.cs b/test/Microsoft.AspNetCore.Certificates.Configuration.Tests/CertificateLoaderTests.cs index b3550bf3d8..8bd889bbe0 100644 --- a/test/Microsoft.AspNetCore.Certificates.Configuration.Tests/CertificateLoaderTests.cs +++ b/test/Microsoft.AspNetCore.Certificates.Configuration.Tests/CertificateLoaderTests.cs @@ -42,7 +42,7 @@ namespace Microsoft.AspNetCore.Certificates.Configuration.Tests Mock.Of()); var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); - Assert.Equal(1, loadedCertificates.Count()); + Assert.Single(loadedCertificates); Assert.Same(certificate, loadedCertificates.ElementAt(0)); certificateFileLoader.VerifyAll(); } @@ -126,11 +126,11 @@ namespace Microsoft.AspNetCore.Certificates.Configuration.Tests certificateStoreLoader.Object); var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); - Assert.Equal(1, loadedCertificates.Count()); + Assert.Single(loadedCertificates); Assert.Same(certificate, loadedCertificates.ElementAt(0)); certificateStoreLoader.VerifyAll(); } - + [Fact] public void ReturnsNull_SingleCertificateName_Store_NotFoundInStore() { @@ -158,7 +158,7 @@ namespace Microsoft.AspNetCore.Certificates.Configuration.Tests certificateStoreLoader.Object); var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); - Assert.Equal(0, loadedCertificates.Count()); + Assert.Empty(loadedCertificates); certificateStoreLoader.VerifyAll(); } @@ -480,7 +480,7 @@ namespace Microsoft.AspNetCore.Certificates.Configuration.Tests ["Certificates:Certificate2:Subject"] = "localhost", ["Certificates:Certificate2:StoreName"] = "My", ["Certificates:Certificate2:StoreLocation"] = "CurrentUser", - ["TestConfig:Certificate"] = "Certificate1;Certificate2" + ["TestConfig:Certificate"] = certificateNames, }) .Build(); @@ -504,7 +504,7 @@ namespace Microsoft.AspNetCore.Certificates.Configuration.Tests certificateStoreLoader.Object); var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); - Assert.Equal(1, loadedCertificates.Count()); + Assert.Single(loadedCertificates); Assert.Same(certificate, loadedCertificates.ElementAt(0)); certificateFileLoader.VerifyAll(); certificateStoreLoader.VerifyAll(); @@ -537,7 +537,7 @@ namespace Microsoft.AspNetCore.Certificates.Configuration.Tests Mock.Of()); var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); - Assert.Equal(1, loadedCertificates.Count()); + Assert.Single(loadedCertificates); Assert.Same(certificate, loadedCertificates.ElementAt(0)); certificateFileLoader.VerifyAll(); } @@ -599,7 +599,7 @@ namespace Microsoft.AspNetCore.Certificates.Configuration.Tests certificateStoreLoader.Object); var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); - Assert.Equal(1, loadedCertificates.Count()); + Assert.Single(loadedCertificates); Assert.Same(certificate, loadedCertificates.ElementAt(0)); certificateStoreLoader.VerifyAll(); } @@ -627,7 +627,7 @@ namespace Microsoft.AspNetCore.Certificates.Configuration.Tests certificateStoreLoader.Object); var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); - Assert.Equal(0, loadedCertificates.Count()); + Assert.Empty(loadedCertificates); certificateStoreLoader.Verify(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())); } @@ -785,7 +785,7 @@ namespace Microsoft.AspNetCore.Certificates.Configuration.Tests certificateStoreLoader.Object); var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificates")); - Assert.Equal(1, loadedCertificates.Count()); + Assert.Single(loadedCertificates); Assert.Same(certificate, loadedCertificates.ElementAt(0)); certificateStoreLoader.Verify(loader => loader.Load("notfound.com", "Root", StoreLocation.LocalMachine, It.IsAny())); certificateStoreLoader.Verify(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())); @@ -927,7 +927,7 @@ namespace Microsoft.AspNetCore.Certificates.Configuration.Tests certificateStoreLoader.Object); var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificates")); - Assert.Equal(1, loadedCertificates.Count()); + Assert.Single(loadedCertificates); Assert.Same(certificate, loadedCertificates.ElementAt(0)); } @@ -1003,7 +1003,7 @@ namespace Microsoft.AspNetCore.Certificates.Configuration.Tests Mock.Of()); var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificates")); - Assert.Equal(0, loadedCertificates.Count()); + Assert.Empty(loadedCertificates); Assert.Single(logger.LogMessages, logMessage => logMessage.LogLevel == LogLevel.Warning && logMessage.Message == "Unable to find a matching certificate for subject 'localhost' in store 'My' in 'CurrentUser'."); diff --git a/test/Microsoft.AspNetCore.Hosting.Tests/HostingApplicationTests.cs b/test/Microsoft.AspNetCore.Hosting.Tests/HostingApplicationTests.cs index fcecc5e0aa..de1dc01899 100644 --- a/test/Microsoft.AspNetCore.Hosting.Tests/HostingApplicationTests.cs +++ b/test/Microsoft.AspNetCore.Hosting.Tests/HostingApplicationTests.cs @@ -42,7 +42,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests // Act var context = hostingApplication.CreateContext(features); - Assert.Equal(1, logger.Scopes.Count); + Assert.Single(logger.Scopes); var pairs = ((IReadOnlyList>)logger.Scopes[0]).ToDictionary(p => p.Key, p => p.Value); Assert.Equal("some correlation id", pairs["CorrelationId"].ToString()); } diff --git a/test/Microsoft.AspNetCore.Hosting.Tests/Internal/HostingEventSourceTests.cs b/test/Microsoft.AspNetCore.Hosting.Tests/Internal/HostingEventSourceTests.cs index 64c0c1bf83..32b51d8a95 100644 --- a/test/Microsoft.AspNetCore.Hosting.Tests/Internal/HostingEventSourceTests.cs +++ b/test/Microsoft.AspNetCore.Hosting.Tests/Internal/HostingEventSourceTests.cs @@ -154,7 +154,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal Assert.Equal(EventLevel.Informational, eventData.Level); Assert.Same(hostingEventSource, eventData.EventSource); Assert.Null(eventData.Message); - Assert.Equal(0, eventData.Payload.Count); + Assert.Empty(eventData.Payload); } [Fact] @@ -176,7 +176,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal Assert.Equal(EventLevel.Error, eventData.Level); Assert.Same(hostingEventSource, eventData.EventSource); Assert.Null(eventData.Message); - Assert.Equal(0, eventData.Payload.Count); + Assert.Empty(eventData.Payload); } private static Exception GetException() diff --git a/test/Microsoft.AspNetCore.Hosting.Tests/StartupManagerTests.cs b/test/Microsoft.AspNetCore.Hosting.Tests/StartupManagerTests.cs index 81d9d51aae..acc23c3bc2 100644 --- a/test/Microsoft.AspNetCore.Hosting.Tests/StartupManagerTests.cs +++ b/test/Microsoft.AspNetCore.Hosting.Tests/StartupManagerTests.cs @@ -244,7 +244,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests app.ApplicationServices = startup.ConfigureServicesDelegate(serviceCollection); var ex = Assert.Throws(() => startup.ConfigureDelegate(app)); - Assert.IsAssignableFrom(typeof(InvalidOperationException), ex.InnerException); + Assert.IsAssignableFrom(ex.InnerException); } [Fact] @@ -259,7 +259,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests var app = new ApplicationBuilder(services); app.ApplicationServices = startup.ConfigureServicesDelegate(serviceCollection); - Assert.IsType(typeof(MyContainer), app.ApplicationServices); + Assert.IsType(app.ApplicationServices); Assert.True(((MyContainer)app.ApplicationServices).FancyMethodCalled); } @@ -275,7 +275,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests var app = new ApplicationBuilder(services); app.ApplicationServices = startup.ConfigureServicesDelegate(serviceCollection); - Assert.IsType(typeof(MyContainer), app.ApplicationServices); + Assert.IsType(app.ApplicationServices); Assert.True(((MyContainer)app.ApplicationServices).FancyMethodCalled); } @@ -291,7 +291,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests var app = new ApplicationBuilder(services); app.ApplicationServices = startup.ConfigureServicesDelegate(serviceCollection); - Assert.IsType(typeof(MyContainer), app.ApplicationServices); + Assert.IsType(app.ApplicationServices); Assert.Equal(((MyContainer)app.ApplicationServices).Environment, EnvironmentName.Production); } @@ -338,7 +338,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests app.ApplicationServices = startup.ConfigureServicesDelegate(serviceCollection); Assert.NotNull(app.ApplicationServices); - Assert.IsNotType(typeof(MyContainer), app.ApplicationServices); + Assert.IsNotType(app.ApplicationServices); } public class MyContainerStartupWithOverloads diff --git a/test/Microsoft.AspNetCore.Hosting.Tests/WebHostBuilderTests.cs b/test/Microsoft.AspNetCore.Hosting.Tests/WebHostBuilderTests.cs index 6353fbda38..4fc0b2f0c8 100644 --- a/test/Microsoft.AspNetCore.Hosting.Tests/WebHostBuilderTests.cs +++ b/test/Microsoft.AspNetCore.Hosting.Tests/WebHostBuilderTests.cs @@ -768,7 +768,7 @@ namespace Microsoft.AspNetCore.Hosting using (var host = (WebHost)builder.Build()) { var sink = host.Services.GetRequiredService(); - Assert.True(sink.Writes.Any(w => w.State.ToString() == "From startup")); + Assert.Contains(sink.Writes, w => w.State.ToString() == "From startup"); } } @@ -865,7 +865,7 @@ namespace Microsoft.AspNetCore.Hosting using (var host = (WebHost)builder.Build()) { var sink = host.Services.GetRequiredService(); - Assert.True(sink.Writes.Any(w => w.Exception?.Message == "Startup exception")); + Assert.Contains(sink.Writes, w => w.Exception?.Message == "Startup exception"); } } @@ -887,7 +887,7 @@ namespace Microsoft.AspNetCore.Hosting Assert.Throws(() => builder.Build()); Assert.NotNull(testSink); - Assert.True(testSink.Writes.Any(w => w.Exception?.Message == "Startup exception")); + Assert.Contains(testSink.Writes, w => w.Exception?.Message == "Startup exception"); } [Fact] diff --git a/test/Microsoft.AspNetCore.Hosting.Tests/WebHostTests.cs b/test/Microsoft.AspNetCore.Hosting.Tests/WebHostTests.cs index ae3316fecd..001f267889 100644 --- a/test/Microsoft.AspNetCore.Hosting.Tests/WebHostTests.cs +++ b/test/Microsoft.AspNetCore.Hosting.Tests/WebHostTests.cs @@ -920,7 +920,7 @@ namespace Microsoft.AspNetCore.Hosting .UseStartup(); var ex = Assert.Throws(() => builder.Build()); - Assert.True(ex.Message.Contains("ConfigureServices")); + Assert.Contains("ConfigureServices", ex.Message); } public class BadConfigureServicesStartup