diff --git a/XmlSchemaClassGenerator.Tests/Compiler.cs b/XmlSchemaClassGenerator.Tests/Compiler.cs index 0782576c..f1f919ba 100644 --- a/XmlSchemaClassGenerator.Tests/Compiler.cs +++ b/XmlSchemaClassGenerator.Tests/Compiler.cs @@ -1,4 +1,4 @@ -using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Emit; using System; @@ -149,11 +149,9 @@ public static Assembly Compile(string name, params string[] contents) .WithOptions(new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); var result = Compiler.GenerateAssembly(compilation); + Assert.Empty(result.Result.Diagnostics.Where(d => d.Severity == DiagnosticSeverity.Error)); + Assert.Empty(result.Result.Diagnostics.Where(d => d.Severity == DiagnosticSeverity.Warning)); Assert.True(result.Result.Success); - var errors = result.Result.Diagnostics.Where(d => d.Severity == DiagnosticSeverity.Error).ToList(); - Assert.False(errors.Any(), string.Join("\n", errors.Select(e => e.GetMessage()))); - var warnings = result.Result.Diagnostics.Where(d => d.Severity == DiagnosticSeverity.Warning).ToList(); - Assert.False(warnings.Any(), string.Join("\n", errors.Select(w => w.GetMessage()))); Assert.NotNull(result.Assembly); Assemblies[name] = result.Assembly; diff --git a/XmlSchemaClassGenerator.Tests/XmlTests.cs b/XmlSchemaClassGenerator.Tests/XmlTests.cs index ca009751..486fddbe 100644 --- a/XmlSchemaClassGenerator.Tests/XmlTests.cs +++ b/XmlSchemaClassGenerator.Tests/XmlTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.CodeDom; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -157,7 +157,7 @@ public void TestListWithPrivatePropertySetters() var iListType = typeof(Collection<>); var collectionPropertyInfos = myClassType.GetProperties().Where(p => p.PropertyType.IsGenericType && iListType.IsAssignableFrom(p.PropertyType.GetGenericTypeDefinition())).OrderBy(p=>p.Name).ToList(); var publicCollectionPropertyInfos = collectionPropertyInfos.Where(p => p.SetMethod.IsPrivate).OrderBy(p=>p.Name).ToList(); - Assert.True(collectionPropertyInfos.Count > 0); + Assert.NotEmpty(collectionPropertyInfos); Assert.Equal(collectionPropertyInfos, publicCollectionPropertyInfos); var myClassInstance = Activator.CreateInstance(myClassType); @@ -189,7 +189,7 @@ public void TestListWithPublicPropertySetters() var iListType = typeof(Collection<>); var collectionPropertyInfos = myClassType.GetProperties().Where(p => p.PropertyType.IsGenericType && iListType.IsAssignableFrom(p.PropertyType.GetGenericTypeDefinition())).OrderBy(p=>p.Name).ToList(); var publicCollectionPropertyInfos = collectionPropertyInfos.Where(p => p.SetMethod.IsPublic).OrderBy(p=>p.Name).ToList(); - Assert.True(collectionPropertyInfos.Count > 0); + Assert.NotEmpty(collectionPropertyInfos); Assert.Equal(collectionPropertyInfos, publicCollectionPropertyInfos); var myClassInstance = Activator.CreateInstance(myClassType); @@ -221,7 +221,7 @@ public void TestListWithPublicPropertySettersWithoutConstructors() var iListType = typeof(Collection<>); var collectionPropertyInfos = myClassType.GetProperties().Where(p => p.PropertyType.IsGenericType && iListType.IsAssignableFrom(p.PropertyType.GetGenericTypeDefinition())).OrderBy(p=>p.Name).ToList(); var publicCollectionPropertyInfos = collectionPropertyInfos.Where(p => p.SetMethod.IsPublic).OrderBy(p=>p.Name).ToList(); - Assert.True(collectionPropertyInfos.Count > 0); + Assert.NotEmpty(collectionPropertyInfos); Assert.Equal(collectionPropertyInfos, publicCollectionPropertyInfos); var myClassInstance = Activator.CreateInstance(myClassType); foreach (var collectionPropertyInfo in publicCollectionPropertyInfos) @@ -253,7 +253,7 @@ public void TestListWithPublicPropertySettersWithoutConstructorsSpecified() var iListType = typeof(Collection<>); var collectionPropertyInfos = myClassType.GetProperties().Where(p => p.PropertyType.IsGenericType && iListType.IsAssignableFrom(p.PropertyType.GetGenericTypeDefinition())).OrderBy(p => p.Name).ToList(); var publicCollectionPropertyInfos = collectionPropertyInfos.Where(p => p.SetMethod.IsPublic).OrderBy(p => p.Name).ToList(); - Assert.True(collectionPropertyInfos.Count > 0); + Assert.NotEmpty(collectionPropertyInfos); Assert.Equal(collectionPropertyInfos, publicCollectionPropertyInfos); var myClassInstance = Activator.CreateInstance(myClassType);