diff --git a/ApiDoctor.DocumentationGeneration.UnitTests/ApiDoctor.DocumentationGeneration.UnitTests.csproj b/ApiDoctor.DocumentationGeneration.UnitTests/ApiDoctor.DocumentationGeneration.UnitTests.csproj index 10ee6cad..8515e892 100644 --- a/ApiDoctor.DocumentationGeneration.UnitTests/ApiDoctor.DocumentationGeneration.UnitTests.csproj +++ b/ApiDoctor.DocumentationGeneration.UnitTests/ApiDoctor.DocumentationGeneration.UnitTests.csproj @@ -24,7 +24,7 @@ - + diff --git a/ApiDoctor.DocumentationGeneration.UnitTests/DescriptionTests.cs b/ApiDoctor.DocumentationGeneration.UnitTests/DescriptionTests.cs index 8ebf2226..2c2838c5 100644 --- a/ApiDoctor.DocumentationGeneration.UnitTests/DescriptionTests.cs +++ b/ApiDoctor.DocumentationGeneration.UnitTests/DescriptionTests.cs @@ -39,7 +39,7 @@ public void TestInlineComplexTypeDescription() ComplexType ct = this.GetComplexType(this.schema, "Test", inlineDescription: inlineDescription); string markDown = this.documentationGenerator.GetMarkDownForType(this.entityFramework, ct); - Assert.IsTrue(markDown.Contains(inlineDescription), "Generated markdown should contain inline description annotation"); + Assert.That(markDown.Contains(inlineDescription), "Generated markdown should contain inline description annotation"); } [Test] @@ -50,7 +50,7 @@ public void TestInlinePropertyDescription() this.AddProperty(ct, "TestProperty", inlineDescription: inlineDescription); string markDown = this.documentationGenerator.GetMarkDownForType(this.entityFramework, ct); - Assert.IsTrue(markDown.Contains(inlineDescription), "Generated markdown should contain inline description annotation"); + Assert.That(markDown.Contains(inlineDescription), "Generated markdown should contain inline description annotation"); } [Test] @@ -60,7 +60,7 @@ public void TestSchemaComplexTypeDescription() ComplexType ct = this.GetComplexType(this.schema, "Test", schemaDescription: schemaDescription); string markDown = this.documentationGenerator.GetMarkDownForType(this.entityFramework, ct); - Assert.IsTrue(markDown.Contains(schemaDescription), "Generated markdown should contain schema description annotation"); + Assert.That(markDown.Contains(schemaDescription), "Generated markdown should contain schema description annotation"); } [Test] @@ -70,7 +70,7 @@ public void TestSchemaPropertyDescription() ComplexType ct = this.GetComplexType(this.schema, "Test", schemaDescription: schemaDescription); string markDown = this.documentationGenerator.GetMarkDownForType(this.entityFramework, ct); - Assert.IsTrue(markDown.Contains(schemaDescription), "Generated markdown should contain schema description annotation"); + Assert.That(markDown.Contains(schemaDescription), "Generated markdown should contain schema description annotation"); } } } \ No newline at end of file diff --git a/ApiDoctor.DocumentationGeneration.UnitTests/NavigationPropertyTests.cs b/ApiDoctor.DocumentationGeneration.UnitTests/NavigationPropertyTests.cs index 6de23fd6..f1a1920c 100644 --- a/ApiDoctor.DocumentationGeneration.UnitTests/NavigationPropertyTests.cs +++ b/ApiDoctor.DocumentationGeneration.UnitTests/NavigationPropertyTests.cs @@ -46,7 +46,7 @@ public void RelationshipTableEntryIsCorrectlyFormattedForEntity() this.AddNavigationProperty(entity, propertyName, propertyType, inlineDescription: description); string markDown = this.documentationGenerator.GetMarkDownForType(this.entityFramework, entity); - Assert.IsTrue(markDown.Contains(expected), "Generated markdown should contain '{0}' Actual:\n{1}", expected, markDown); + Assert.That(markDown.Contains(expected), Is.True, "Generated markdown should contain '{0}' Actual:\n{1}", expected, markDown); } [Test] @@ -62,7 +62,7 @@ public void RelationshipTableEntryIsCorrectlyFormattedForEntityCollection() this.AddNavigationProperty(entity, propertyName, propertyType, inlineDescription: description); string markDown = this.documentationGenerator.GetMarkDownForType(this.entityFramework, entity); - Assert.IsTrue(markDown.Contains(expected), "Generated markdown should contain '{0}' Actual:\n{1}", expected, markDown); + Assert.That(markDown.Contains(expected), Is.True, "Generated markdown should contain '{0}' Actual:\n{1}", expected, markDown); } } } \ No newline at end of file diff --git a/ApiDoctor.DocumentationGeneration.UnitTests/PropertyTests.cs b/ApiDoctor.DocumentationGeneration.UnitTests/PropertyTests.cs index 3568994d..e011df14 100644 --- a/ApiDoctor.DocumentationGeneration.UnitTests/PropertyTests.cs +++ b/ApiDoctor.DocumentationGeneration.UnitTests/PropertyTests.cs @@ -47,7 +47,7 @@ public void PropertyTableEntryIsCorrectlyFormattedForComplexType() string markDown = this.documentationGenerator.GetMarkDownForType(this.entityFramework, ct); - Assert.IsTrue(markDown.Contains(expected), "Generated markdown should contain '{0}' Actual:\n{1}", expected, markDown); + Assert.That(markDown.Contains(expected), Is.True, "Generated markdown should contain '{0}' Actual:\n{1}", expected, markDown); } [Test] @@ -64,7 +64,7 @@ public void PropertyTableEntryIsCorrectlyFormattedForComplexTypeCollection() string markDown = this.documentationGenerator.GetMarkDownForType(this.entityFramework, ct); - Assert.IsTrue(markDown.Contains(expected), "Generated markdown should contain '{0}' Actual:\n{1}", expected, markDown); + Assert.That(markDown.Contains(expected), Is.True, "Generated markdown should contain '{0}' Actual:\n{1}", expected, markDown); } [Test] @@ -78,7 +78,7 @@ public void PropertyTableEntryIsCorrectlyFormattedForPrimitiveType() this.AddProperty(ct, propertyName, type: $"Edm.{propertyType}", inlineDescription: description); string markDown = this.documentationGenerator.GetMarkDownForType(this.entityFramework, ct); - Assert.IsTrue(markDown.Contains(expected), "Generated markdown should contain '{0}' Actual:\n{1}", expected, markDown); + Assert.That(markDown.Contains(expected), Is.True, "Generated markdown should contain '{0}' Actual:\n{1}", expected, markDown); } [Test] @@ -92,7 +92,7 @@ public void PropertyTableEntryIsCorrectlyFormattedForPrimitiveTypeCollection() this.AddProperty(ct, propertyName, type: $"Collection(Edm.{propertyType})", inlineDescription: description); string markDown = this.documentationGenerator.GetMarkDownForType(this.entityFramework, ct); - Assert.IsTrue(markDown.Contains(expected), "Generated markdown should contain '{0}' Actual:\n{1}", expected, markDown); + Assert.That(markDown.Contains(expected), Is.True, $"Generated markdown should contain '{expected}' Actual:\n{markDown}"); } } } \ No newline at end of file diff --git a/ApiDoctor.DocumentationGeneration.UnitTests/ResourceRoundTripTests.cs b/ApiDoctor.DocumentationGeneration.UnitTests/ResourceRoundTripTests.cs index 987ed8b2..79466a10 100644 --- a/ApiDoctor.DocumentationGeneration.UnitTests/ResourceRoundTripTests.cs +++ b/ApiDoctor.DocumentationGeneration.UnitTests/ResourceRoundTripTests.cs @@ -59,7 +59,7 @@ public void TestRoudTripEntityType() DocFile testFile = this.GetDocFileForEntityType(entity); - Assert.AreEqual(1, testFile.Resources.Length, "Expected to find one resource"); + Assert.That(1, Is.EqualTo(testFile.Resources.Length), "Expected to find one resource"); var resource = testFile.Resources[0]; this.VerifyEntityType(entity, resource); } @@ -76,7 +76,7 @@ public void TestRoundTripComplexType() DocFile testFile = this.GetDocFileForComplexType(testType); - Assert.AreEqual(1, testFile.Resources.Length, "Expected to find one resource"); + Assert.That(1, Is.EqualTo(testFile.Resources.Length), "Expected to find one resource"); var resource = testFile.Resources[0]; this.VerifyComplexType(testType, resource); } @@ -90,7 +90,7 @@ private DocFile GetDocFileForComplexType(ComplexType testType) DocFile testFile = new DocFileForTesting(markDown, @"\resources.md", @"\resources.md", docSet); var issues = new IssueLogger(); testFile.Scan(string.Empty, issues.For("testFile")); - Assert.IsFalse(issues.Issues.WereWarningsOrErrors(), "Expected no validation warnings/errors: {0}", issues.Issues.ErrorsToString()); + Assert.That(issues.Issues.WereWarningsOrErrors(), Is.False, "Expected no validation warnings/errors: {0}", issues.Issues.ErrorsToString()); return testFile; } @@ -103,44 +103,44 @@ private DocFile GetDocFileForEntityType(EntityType testType) DocFile testFile = new DocFileForTesting(markDown, @"\resources.md", @"\resources.md", docSet); var issues = new IssueLogger(); testFile.Scan(string.Empty, issues.For("testFile")); - Assert.IsFalse(issues.Issues.WereWarningsOrErrors(), "Expected no validation warnings/errors: {0}", issues.Issues.Where(e => e.IsWarningOrError).ErrorsToString()); + Assert.That(issues.Issues.WereWarningsOrErrors(), Is.False, "Expected no validation warnings/errors: {0}", issues.Issues.Where(e => e.IsWarningOrError).ErrorsToString()); return testFile; } private void VerifyComplexType(ComplexType testType, ResourceDefinition resource) { - Assert.AreEqual($"{this.schema.Namespace}.{testType.Name}", resource.Name, "Resource name does not match"); + Assert.That($"{this.schema.Namespace}.{testType.Name}", Is.EqualTo(resource.Name), "Resource name does not match"); // Ignore the odata.type property var resourceProperties = resource.Parameters.Where(p => p.Name != "@odata.type" && !p.IsNavigatable).ToList(); - Assert.AreEqual(testType.Properties.Count, resourceProperties.Count(), "Property count does not match"); + Assert.That(testType.Properties.Count, Is.EqualTo(resourceProperties.Count()), "Property count does not match"); for (int i = 0; i < resourceProperties.Count; i++) { - Assert.AreEqual(testType.Properties[i].Name, resourceProperties[i].Name, "Name of property does not match"); - Assert.AreEqual(testType.Properties[i].Type, resourceProperties[i].Type.ODataResourceName(), "Type of property {0} does not match", testType.Properties[i].Name); - Assert.AreEqual(testType.Properties[i].ToDocumentationProperty(this.entityFramework, testType).Description, resourceProperties[i].Description, "Description for property {0} does not match", testType.Properties[i].Name); + Assert.That(testType.Properties[i].Name, Is.EqualTo(resourceProperties[i].Name), "Name of property does not match"); + Assert.That(testType.Properties[i].Type, Is.EqualTo(resourceProperties[i].Type.ODataResourceName()), "Type of property {0} does not match", testType.Properties[i].Name); + Assert.That(testType.Properties[i].ToDocumentationProperty(this.entityFramework, testType).Description, Is.EqualTo(resourceProperties[i].Description), "Description for property {0} does not match", testType.Properties[i].Name); } } private void VerifyEntityType(EntityType testType, ResourceDefinition resource) { this.VerifyComplexType(testType, resource); - Assert.AreEqual($"{this.schema.Namespace}.{testType.Name}", resource.Name, "Resource name does not match"); + Assert.That($"{this.schema.Namespace}.{testType.Name}", Is.EqualTo(resource.Name), "Resource name does not match"); // Ignore the odata.type property var navigationProperties = resource.Parameters.Where(p => p.IsNavigatable).ToList(); - Assert.AreEqual(testType.NavigationProperties.Count, navigationProperties.Count(), "Navigation Property count does not match"); + Assert.That(testType.NavigationProperties.Count, Is.EqualTo(navigationProperties.Count()), "Navigation Property count does not match"); for (int i = 0; i < navigationProperties.Count; i++) { - Assert.AreEqual(testType.NavigationProperties[i].Name, navigationProperties[i].Name, "Name of navigation property does not match"); + Assert.That(testType.NavigationProperties[i].Name, Is.EqualTo(navigationProperties[i].Name), "Name of navigation property does not match"); // TODO: Fix parsing of Navigation Property types // Assert.AreEqual(testType.NavigationProperties[i].Type, navigationProperties[i].Type.ODataResourceName(), "Type of navigation property {0} does not match", testType.NavigationProperties[i].Name); - Assert.AreEqual(testType.NavigationProperties[i].ToDocumentationProperty(this.entityFramework, testType).Description, navigationProperties[i].Description, "Description for property {0} does not match", testType.NavigationProperties[i].Name); + Assert.That(testType.NavigationProperties[i].ToDocumentationProperty(this.entityFramework, testType).Description, Is.EqualTo(navigationProperties[i].Description), "Description for property {0} does not match", testType.NavigationProperties[i].Name); } } } diff --git a/ApiDoctor.Validation.UnitTests/ApiDoctor.Validation.UnitTests.csproj b/ApiDoctor.Validation.UnitTests/ApiDoctor.Validation.UnitTests.csproj index 3f080e95..e3f9d492 100644 --- a/ApiDoctor.Validation.UnitTests/ApiDoctor.Validation.UnitTests.csproj +++ b/ApiDoctor.Validation.UnitTests/ApiDoctor.Validation.UnitTests.csproj @@ -41,7 +41,7 @@ - + diff --git a/ApiDoctor.Validation.UnitTests/BrokenLinkTests.cs b/ApiDoctor.Validation.UnitTests/BrokenLinkTests.cs index 3adb0f98..8150fa42 100644 --- a/ApiDoctor.Validation.UnitTests/BrokenLinkTests.cs +++ b/ApiDoctor.Validation.UnitTests/BrokenLinkTests.cs @@ -49,11 +49,11 @@ [Up one level](../anotherfile.md) TestableDocFile file = new TestableDocFile(markdown); var issues = new IssueLogger(); - Assert.IsTrue(file.Scan(string.Empty, issues)); - Assert.IsEmpty(issues.Issues.WarningsOrErrorsOnly()); + Assert.That(file.Scan(string.Empty, issues)); + Assert.That(issues.Issues.WarningsOrErrorsOnly(), Is.Empty); - Assert.IsTrue(file.ValidateNoBrokenLinks(false, issues, true)); - Assert.IsEmpty(issues.Issues.WarningsOrErrorsOnly()); + Assert.That(file.ValidateNoBrokenLinks(false, issues, true)); + Assert.That(issues.Issues.WarningsOrErrorsOnly(), Is.Empty); } @@ -75,14 +75,14 @@ This link goes [up one level](../anotherfile.md) var issues = new IssueLogger(); - Assert.IsTrue(file.Scan(string.Empty, issues)); + Assert.That(file.Scan(string.Empty, issues)); var realErrors = from e in issues.Issues where e.IsWarning || e.IsError select e; - Assert.IsEmpty(realErrors); + Assert.That(realErrors, Is.Empty); - Assert.IsFalse(file.ValidateNoBrokenLinks(false, issues, false)); + Assert.That(file.ValidateNoBrokenLinks(false, issues, false), Is.False); realErrors = from e in issues.Issues where e.IsWarning || e.IsError select e; - Assert.AreEqual(1, realErrors.Count()); - Assert.IsTrue(realErrors.First().Code == ValidationErrorCode.MissingLinkSourceId); + Assert.That(1, Is.EqualTo(realErrors.Count())); + Assert.That(realErrors.First().Code == ValidationErrorCode.MissingLinkSourceId); } @@ -115,12 +115,12 @@ This link goes [up one level](../anotherfile.md) var issues = new IssueLogger(); - Assert.IsTrue(file.Scan(string.Empty, issues)); - Assert.IsEmpty(issues.Issues.WarningsOrErrorsOnly()); + Assert.That(file.Scan(string.Empty, issues)); + Assert.That(issues.Issues.WarningsOrErrorsOnly(), Is.Empty); - Assert.IsFalse(file.ValidateNoBrokenLinks(false, issues, false)); - Assert.AreEqual(1, issues.Issues.WarningsOrErrorsOnly().Count()); - Assert.IsTrue(issues.Issues.Any(i => i.Code == ValidationErrorCode.LinkDestinationNotFound)); + Assert.That(file.ValidateNoBrokenLinks(false, issues, false), Is.False); + Assert.That(1, Is.EqualTo(issues.Issues.WarningsOrErrorsOnly().Count())); + Assert.That(issues.Issues.Any(i => i.Code == ValidationErrorCode.LinkDestinationNotFound)); } [Test] @@ -142,13 +142,13 @@ This link goes [up one level](../anotherfile.md) var issues = new IssueLogger(); - Assert.IsTrue(file.Scan(string.Empty, issues)); - Assert.IsEmpty(issues.Issues.WarningsOrErrorsOnly()); + Assert.That(file.Scan(string.Empty, issues)); + Assert.That(issues.Issues.WarningsOrErrorsOnly(), Is.Empty); - Assert.IsFalse(file.ValidateNoBrokenLinks(false, issues, false)); - Assert.AreEqual(2, issues.Issues.WarningsOrErrorsOnly().Count()); - Assert.IsTrue(issues.Issues.Any(i => i.Code == ValidationErrorCode.MissingLinkSourceId)); - Assert.IsTrue(issues.Issues.Any(i => i.Code == ValidationErrorCode.LinkDestinationNotFound)); + Assert.That(file.ValidateNoBrokenLinks(false, issues, false), Is.False); + Assert.That(2, Is.EqualTo(issues.Issues.WarningsOrErrorsOnly().Count())); + Assert.That(issues.Issues.Any(i => i.Code == ValidationErrorCode.MissingLinkSourceId)); + Assert.That(issues.Issues.Any(i => i.Code == ValidationErrorCode.LinkDestinationNotFound)); } } diff --git a/ApiDoctor.Validation.UnitTests/HttpParserTests.cs b/ApiDoctor.Validation.UnitTests/HttpParserTests.cs index eeadb31b..107e49e7 100644 --- a/ApiDoctor.Validation.UnitTests/HttpParserTests.cs +++ b/ApiDoctor.Validation.UnitTests/HttpParserTests.cs @@ -17,7 +17,7 @@ public class HttpParserTests public void ParseOdataUrl(string odataUrl, string actualUrl) { var request = HttpParser.ParseHttpRequest(odataUrl); - Assert.AreEqual(actualUrl, request.Url, "Parsed Url should be equal to request header url"); + Assert.That(actualUrl, Is.EqualTo(request.Url), "Parsed Url should be equal to request header url"); } [Test] @@ -27,7 +27,7 @@ public void ParseOdataUrl(string odataUrl, string actualUrl) public void HttpVersionShouldBeRespected(string odataUrl, string httpVersion) { var request = HttpParser.ParseHttpRequest(odataUrl); - Assert.AreEqual(httpVersion, request.HttpVersion, "When HttpVersion is specified, should be respected"); + Assert.That(httpVersion, Is.EqualTo(request.HttpVersion), "When HttpVersion is specified, should be respected"); } [Test] @@ -36,7 +36,7 @@ public void HttpVersionShouldBeRespected(string odataUrl, string httpVersion) public void HttpVersionShouldDefaultToHttp1(string odataUrl) { var request = HttpParser.ParseHttpRequest(odataUrl); - Assert.AreEqual("HTTP/1.1", request.HttpVersion, "When HttpVersion is not specified, default to HTTP/1.1"); + Assert.That("HTTP/1.1", Is.EqualTo(request.HttpVersion), "When HttpVersion is not specified, default to HTTP/1.1"); } [Test] @@ -44,7 +44,7 @@ public void ParseHttpRequest() { var exampleRequest = FullHttpRequest; var parsedRequest = HttpParser.ParseHttpRequest(exampleRequest); - Assert.NotNull(parsedRequest); + Assert.That(parsedRequest, Is.Not.Null); } [Test] @@ -54,7 +54,7 @@ public void ParseHttpRequest() public void ParseOdataMethod(string odataUrl, string method) { var request = HttpParser.ParseHttpRequest(odataUrl); - Assert.AreEqual(method, request.Method, "Parsed Method should be equal to request header method"); + Assert.That(method, Is.EqualTo(request.Method), "Parsed Method should be equal to request header method"); } } } \ No newline at end of file diff --git a/ApiDoctor.Validation.UnitTests/JsonPathTest.cs b/ApiDoctor.Validation.UnitTests/JsonPathTest.cs index dbab2077..9faf51e5 100644 --- a/ApiDoctor.Validation.UnitTests/JsonPathTest.cs +++ b/ApiDoctor.Validation.UnitTests/JsonPathTest.cs @@ -73,7 +73,7 @@ public void JsonPathRootObject() var value = JsonPath.ValueFromJsonPath(json, "$"); var resultJson = JsonConvert.SerializeObject(value); - Assert.AreEqual(json, resultJson); + Assert.That(json, Is.EqualTo(resultJson)); } [Test] @@ -86,7 +86,7 @@ public void JsonPathInvalidPath() public void JsonPathTopLevelValue() { var value = JsonPath.ValueFromJsonPath(this.GetJson(), "$.id"); - Assert.AreEqual("1234", value); + Assert.That("1234", Is.EqualTo(value)); } [Test] @@ -100,14 +100,14 @@ public void JsonPathSecondLevelObjectValue() var foundObjectJson = JsonConvert.SerializeObject(value); var dynamicObjectJson = JsonConvert.SerializeObject(smallThumbnailObject); - Assert.AreEqual(dynamicObjectJson, foundObjectJson); + Assert.That(dynamicObjectJson, Is.EqualTo(foundObjectJson)); } [Test] public void JsonPathThirdLevelValue() { var value = JsonPath.ValueFromJsonPath(this.GetJson(), "$.thumbnails.small.url"); - Assert.AreEqual("http://small", value); + Assert.That("http://small", Is.EqualTo(value)); } [Test] @@ -121,21 +121,21 @@ public void JsonPathArrayTest() var foundObjectJson = JsonConvert.SerializeObject(value); var dynamicObjectJson = JsonConvert.SerializeObject(firstChild); - Assert.AreEqual(dynamicObjectJson, foundObjectJson); + Assert.That(dynamicObjectJson, Is.EqualTo(foundObjectJson)); } [Test] public void JsonPathArrayWithSecondLevelTest() { var value = JsonPath.ValueFromJsonPath(this.GetJson(), "$.children[0].name"); - Assert.AreEqual("first_file.txt", value); + Assert.That("first_file.txt", Is.EqualTo(value)); } [Test] public void JsonPathWithPeriodInPropertyNameTest() { var value = JsonPath.ValueFromJsonPath(this.GetJson(), "$.['@content.downloadUrl']"); - Assert.AreEqual("https://foobar.com/something", value); + Assert.That("https://foobar.com/something", Is.EqualTo(value)); } [Test] @@ -144,7 +144,7 @@ public void JsonPathSetTopLevelValue() string modifiedJson = JsonPath.SetValueForJsonPath(this.GetJson(), "$.id", "5678"); dynamic result = JsonConvert.DeserializeObject(modifiedJson); - Assert.AreEqual(JsonPath.ConvertValueForOutput(result.id), "5678"); + Assert.That(JsonPath.ConvertValueForOutput(result.id), Is.EqualTo("5678")); } [Test] @@ -153,7 +153,7 @@ public void JsonPathSetSecondLevelValue() string modifiedJson = JsonPath.SetValueForJsonPath(this.GetJson(), "$.another.value", "something-else-completely"); dynamic result = JsonConvert.DeserializeObject(modifiedJson); - Assert.AreEqual(JsonPath.ConvertValueForOutput(result.another.value), "something-else-completely"); + Assert.That(JsonPath.ConvertValueForOutput(result.another.value), Is.EqualTo("something-else-completely")); } [Test] @@ -162,7 +162,7 @@ public void JsonPathSetArrayValue() string modifiedJson = JsonPath.SetValueForJsonPath(this.GetJson(), "$.children[0].name", "something-else-completely"); dynamic result = JsonConvert.DeserializeObject(modifiedJson); - Assert.AreEqual(JsonPath.ConvertValueForOutput(result.children[0].name), "something-else-completely"); + Assert.That(JsonPath.ConvertValueForOutput(result.children[0].name), Is.EqualTo("something-else-completely")); } [Test] @@ -171,7 +171,7 @@ public void JsonPathSetNewTopLevelValue() string modifiedJson = JsonPath.SetValueForJsonPath(this.GetJson(), "$.zippy", "do-dah"); dynamic result = JsonConvert.DeserializeObject(modifiedJson); - Assert.AreEqual(JsonPath.ConvertValueForOutput(result.zippy), "do-dah"); + Assert.That(JsonPath.ConvertValueForOutput(result.zippy), Is.EqualTo("do-dah")); } [Test] @@ -180,7 +180,7 @@ public void JsonPathSetNewSecondLevelValue() string modifiedJson = JsonPath.SetValueForJsonPath(this.GetJson(), "$.zippy.foo", "do-dah"); dynamic result = JsonConvert.DeserializeObject(modifiedJson); - Assert.AreEqual(JsonPath.ConvertValueForOutput(result.zippy.foo), "do-dah"); + Assert.That(JsonPath.ConvertValueForOutput(result.zippy.foo), Is.EqualTo("do-dah")); } [Test] @@ -190,7 +190,7 @@ public void JsonPathComplexTypeName() string modifiedJson = JsonPath.SetValueForJsonPath(json, "$.['@name.conflictBehavior']", "replace"); dynamic result = JsonConvert.DeserializeObject(modifiedJson); - Assert.AreEqual(JsonPath.ConvertValueForOutput(result["@name.conflictBehavior"]), "replace"); + Assert.That(JsonPath.ConvertValueForOutput(result["@name.conflictBehavior"]), Is.EqualTo("replace")); } } diff --git a/ApiDoctor.Validation.UnitTests/MultipartMimeTests.cs b/ApiDoctor.Validation.UnitTests/MultipartMimeTests.cs index 59b91d60..11aa2e15 100644 --- a/ApiDoctor.Validation.UnitTests/MultipartMimeTests.cs +++ b/ApiDoctor.Validation.UnitTests/MultipartMimeTests.cs @@ -43,8 +43,8 @@ public void RoundtripTest() MultipartMime.MultipartMimeContent message2 = new MultipartMime.MultipartMimeContent(message.ContentType, body1); string body2 = message2.ToString(); - Assert.AreEqual(body1.Length, body2.Length, "Body length changed between roundtrips."); - Assert.AreEqual(body1, body2, "Body text was different between roundtrips."); + Assert.That(body1.Length, Is.EqualTo(body2.Length), "Body length changed between roundtrips."); + Assert.That(body1, Is.EqualTo(body2), "Body text was different between roundtrips."); } } } diff --git a/ApiDoctor.Validation.UnitTests/NullableTests.cs b/ApiDoctor.Validation.UnitTests/NullableTests.cs index a758b2d6..99caa272 100644 --- a/ApiDoctor.Validation.UnitTests/NullableTests.cs +++ b/ApiDoctor.Validation.UnitTests/NullableTests.cs @@ -51,8 +51,8 @@ public void NullPropertyShouldBeOk() var testExample = new JsonExample(json); var issues = new IssueLogger(); - Assert.IsTrue(nullableSchema.ValidateJson(testExample, issues, new Dictionary(), new ValidationOptions())); - Assert.AreEqual(0, issues.Issues.Count()); + Assert.That(nullableSchema.ValidateJson(testExample, issues, new Dictionary(), new ValidationOptions())); + Assert.That(0, Is.EqualTo(issues.Issues.Count())); } [Test] @@ -71,11 +71,11 @@ public void NullPropertyShouldGenerateWarning() var testExample = new JsonExample(json); var issues = new IssueLogger(); - Assert.IsFalse(nullableSchema.ValidateJson(testExample, issues, new Dictionary(), new ValidationOptions())); - Assert.AreEqual(1, issues.Issues.Count()); + Assert.That(nullableSchema.ValidateJson(testExample, issues, new Dictionary(), new ValidationOptions()), Is.False); + Assert.That(1, Is.EqualTo(issues.Issues.Count())); var error = issues.Issues.First(); - Assert.AreEqual(ValidationErrorCode.NullPropertyValue, error.Code); + Assert.That(ValidationErrorCode.NullPropertyValue, Is.EqualTo(error.Code)); } public JsonSchema SchemaForNullTest(bool expectNulls) diff --git a/ApiDoctor.Validation.UnitTests/ObjectGraphMergerTests.cs b/ApiDoctor.Validation.UnitTests/ObjectGraphMergerTests.cs index 8f5e7b1c..7ad2482b 100644 --- a/ApiDoctor.Validation.UnitTests/ObjectGraphMergerTests.cs +++ b/ApiDoctor.Validation.UnitTests/ObjectGraphMergerTests.cs @@ -49,10 +49,10 @@ public void MergeSimpleTypes() var merger = new ObjectGraphMerger(itemsToMerge); var result = merger.Merge(); - Assert.IsNotNull(result); - Assert.AreEqual("Ryan", result.Name); - Assert.AreEqual(true, result.IsAuthor); - Assert.IsNull(result.ExpectedToBeNull); + Assert.That(result, Is.Not.Null); + Assert.That("Ryan", Is.EqualTo(result.Name)); + Assert.That(true, Is.EqualTo(result.IsAuthor)); + Assert.That(result.ExpectedToBeNull, Is.Null); } [Test] @@ -80,22 +80,22 @@ public void MergeCollection() var merger = new ObjectGraphMerger(graphsToMerge); var result = merger.Merge(); - Assert.IsNotNull(result); - Assert.IsNotNull(result.Authors); - Assert.AreEqual(3, result.Authors.Length); + Assert.That(result, Is.Not.Null); + Assert.That(result.Authors, Is.Not.Null); + Assert.That(3, Is.EqualTo(result.Authors.Length)); foreach(var author in result.Authors) { switch(author.Name) { case "Ryan": - Assert.IsTrue(author.IsAuthor); + Assert.That(author.IsAuthor); break; case "Daron": - Assert.IsFalse(author.IsAuthor); + Assert.That(author.IsAuthor, Is.False); break; case "Brad": - Assert.IsFalse(author.IsAuthor); + Assert.That(author.IsAuthor, Is.False); break; default: Assert.Fail("Unexpected author name was returned"); diff --git a/ApiDoctor.Validation.UnitTests/ResourceStringValidationTests.cs b/ApiDoctor.Validation.UnitTests/ResourceStringValidationTests.cs index 1703559e..b5ad1959 100644 --- a/ApiDoctor.Validation.UnitTests/ResourceStringValidationTests.cs +++ b/ApiDoctor.Validation.UnitTests/ResourceStringValidationTests.cs @@ -43,7 +43,7 @@ static DocFile GetDocFile() var issues = new IssueLogger(); testFile.Scan(string.Empty, issues); - Assert.IsFalse(issues.Issues.WereWarningsOrErrors(), "Detected warnings or errors when reading the example markdown file."); + Assert.That(issues.Issues.WereWarningsOrErrors(), Is.False, "Detected warnings or errors when reading the example markdown file."); return testFile; } @@ -64,8 +64,8 @@ public void ResourceStringValidationValidExampleTest() var issues = new IssueLogger(); bool result = schema.ValidateExpectedResponse(method, issues); - Assert.IsTrue(result); - Assert.IsEmpty(issues.Issues.Where(i => i.IsWarningOrError), "Validation errors were detected"); + Assert.That(result); + Assert.That(issues.Issues.Where(i => i.IsWarningOrError), Is.Empty, "Validation errors were detected"); } /// @@ -84,10 +84,10 @@ public void ResourceStringValidationBadTimestamp() var issues = new IssueLogger(); bool result = schema.ValidateExpectedResponse(method, issues); - Assert.IsFalse(result); - Assert.IsTrue(issues.Issues.WereErrors()); + Assert.That(result, Is.False); + Assert.That(issues.Issues.WereErrors()); - Assert.IsNotNull(issues.Issues.SingleOrDefault(x => x.Code == ValidationErrorCode.ExpectedTypeDifferent)); + Assert.That(issues.Issues.SingleOrDefault(x => x.Code == ValidationErrorCode.ExpectedTypeDifferent), Is.Not.Null); } /// @@ -106,10 +106,10 @@ public void ResourceStringValidationBadEnumValue() var issues = new IssueLogger(); bool result = schema.ValidateExpectedResponse(method, issues); - Assert.IsFalse(result); - Assert.IsTrue(issues.Issues.WereErrors()); + Assert.That(result, Is.False); + Assert.That(issues.Issues.WereErrors()); - Assert.IsNotNull(issues.Issues.SingleOrDefault(x => x.Code == ValidationErrorCode.InvalidEnumeratedValueString)); + Assert.That(issues.Issues.SingleOrDefault(x => x.Code == ValidationErrorCode.InvalidEnumeratedValueString), Is.Not.Null); } /// @@ -128,10 +128,10 @@ public void ResourceStringValidationBadUrlValue() var issues = new IssueLogger(); bool result = schema.ValidateExpectedResponse(method, issues); - Assert.IsFalse(result); - Assert.IsTrue(issues.Issues.WereErrors()); + Assert.That(result, Is.False); + Assert.That(issues.Issues.WereErrors()); - Assert.IsNotNull(issues.Issues.SingleOrDefault(x => x.Code == ValidationErrorCode.InvalidUrlString)); + Assert.That(issues.Issues.SingleOrDefault(x => x.Code == ValidationErrorCode.InvalidUrlString), Is.Not.Null); } } diff --git a/ApiDoctor.Validation.UnitTests/SchemaBuilderTests.cs b/ApiDoctor.Validation.UnitTests/SchemaBuilderTests.cs index 6b8367aa..61f8c1c2 100644 --- a/ApiDoctor.Validation.UnitTests/SchemaBuilderTests.cs +++ b/ApiDoctor.Validation.UnitTests/SchemaBuilderTests.cs @@ -59,31 +59,31 @@ public void SimpleTypesSchemaTest() { JsonSchema schema = SimpleSchemaExample(); - Assert.AreEqual(5, schema.Properties.Length); + Assert.That(5, Is.EqualTo(schema.Properties.Length)); foreach (var property in schema.Properties) { switch (property.Name) { case "stringProp": - Assert.AreEqual(property.Type, ParameterDataType.String); - Assert.AreEqual("string", property.OriginalValue); + Assert.That(property.Type, Is.EqualTo(ParameterDataType.String)); + Assert.That("string", Is.EqualTo(property.OriginalValue)); break; case "urlProp": - Assert.AreEqual(property.Type, ParameterDataType.String); - Assert.AreEqual("url", property.OriginalValue); + Assert.That(property.Type, Is.EqualTo(ParameterDataType.String)); + Assert.That("url", Is.EqualTo(property.OriginalValue)); break; case "numberProp": - Assert.AreEqual(property.Type, ParameterDataType.Int64); - Assert.AreEqual(123, Int32.Parse(property.OriginalValue)); + Assert.That(property.Type, Is.EqualTo(ParameterDataType.Int64)); + Assert.That(123, Is.EqualTo(int.Parse(property.OriginalValue))); break; case "floatProp": - Assert.AreEqual(property.Type, ParameterDataType.Double); - Assert.AreEqual(123.121, double.Parse(property.OriginalValue)); + Assert.That(property.Type, Is.EqualTo(ParameterDataType.Double)); + Assert.That(123.121, Is.EqualTo(double.Parse(property.OriginalValue))); break; case "dateProp": - Assert.AreEqual(property.Type, ParameterDataType.DateTimeOffset); - Assert.AreEqual("datetime", property.OriginalValue); + Assert.That(property.Type, Is.EqualTo(ParameterDataType.DateTimeOffset)); + Assert.That("datetime", Is.EqualTo(property.OriginalValue)); break; default: Assert.Fail("Unexpected property name: " + property.Name); @@ -97,21 +97,21 @@ public void FacetTypeSchema() { var schema = FacetSchemaExample(); - Assert.AreEqual(2, schema.Properties.Length); + Assert.That(2, Is.EqualTo(schema.Properties.Length)); foreach (var prop in schema.Properties) { - Assert.IsTrue(prop.Type.IsObject); - Assert.IsNull(prop.Type.CustomMembers); + Assert.That(prop.Type.IsObject); + Assert.That(prop.Type.CustomMembers, Is.Null); switch (prop.Name) { case "complexTypeA": - Assert.IsTrue(prop.Type.IsObject); - Assert.AreEqual("resource.a", prop.Type.CustomTypeName); + Assert.That(prop.Type.IsObject); + Assert.That("resource.a", Is.EqualTo(prop.Type.CustomTypeName)); break; case "complexTypeB": - Assert.IsTrue(prop.Type.IsObject); - Assert.AreEqual("resource.b", prop.Type.CustomTypeName); + Assert.That(prop.Type.IsObject); + Assert.That("resource.b", Is.EqualTo(prop.Type.CustomTypeName)); break; } } @@ -123,7 +123,7 @@ public void ArrayTypeSchema() { JsonSchema schema = ArraySchemaExample(); - Assert.AreEqual(3, schema.Properties.Length); + Assert.That(3, Is.EqualTo(schema.Properties.Length)); foreach (var prop in schema.Properties) { switch (prop.Name) @@ -167,8 +167,8 @@ public void TestStringEnumCollection() JsonSchema schema = new JsonSchema(json, null); var property = schema.Properties.Single(); - Assert.IsTrue(property.Type.IsCollection); - Assert.IsTrue(property.Type.CollectionResourceType == SimpleDataType.String); + Assert.That(property.Type.IsCollection); + Assert.That(property.Type.CollectionResourceType == SimpleDataType.String); } [Test] @@ -178,18 +178,18 @@ public void TestStringSpecificFormatDateTime() JsonSchema schema = new JsonSchema(json, null); foreach (var prop in schema.Properties) { - Assert.IsTrue(prop.Type.Type == SimpleDataType.DateTimeOffset); + Assert.That(prop.Type.Type == SimpleDataType.DateTimeOffset); } } public void CheckJsonProperty(ParameterDefinition prop, ParameterDataType expectedType = null, bool? customMembersIsNull = null) { if (expectedType != null) - Assert.AreEqual(expectedType, prop.Type); + Assert.That(expectedType, Is.EqualTo(prop.Type)); if (customMembersIsNull != null && customMembersIsNull.Value) - Assert.IsNull(prop.Type.CustomMembers); + Assert.That(prop.Type.CustomMembers, Is.Null); else if (customMembersIsNull != null && !customMembersIsNull.Value) - Assert.IsNotNull(prop.Type.CustomMembers); + Assert.That(prop.Type.CustomMembers, Is.Not.Null); } } diff --git a/ApiDoctor.Validation.UnitTests/SchemaValidatorTests.cs b/ApiDoctor.Validation.UnitTests/SchemaValidatorTests.cs index 07596e0a..03130bb9 100644 --- a/ApiDoctor.Validation.UnitTests/SchemaValidatorTests.cs +++ b/ApiDoctor.Validation.UnitTests/SchemaValidatorTests.cs @@ -58,8 +58,8 @@ public void SimpleTypeValidationValid() string json = JsonConvert.SerializeObject(newObj, Settings); var issues = new IssueLogger(); - Assert.IsTrue(schema.ValidateJson(new JsonExample(json), issues, null, null)); - Assert.AreEqual(0, issues.Issues.Count()); + Assert.That(schema.ValidateJson(new JsonExample(json), issues, null, null)); + Assert.That(0, Is.EqualTo(issues.Issues.Count())); } [Test] @@ -81,9 +81,9 @@ public void SimpleTypeValidationWrongPropertyType() string json = JsonConvert.SerializeObject(newObj, Settings); var issues = new IssueLogger(); - Assert.IsFalse(schema.ValidateJson(new JsonExample(json), issues, null, null)); - Assert.IsTrue(issues.Issues.All(error => error.Code == ValidationErrorCode.ExpectedTypeDifferent)); - Assert.AreEqual(2, issues.Issues.Count(), "Expected 2 errors in the response"); + Assert.That(schema.ValidateJson(new JsonExample(json), issues, null, null), Is.False); + Assert.That(issues.Issues.All(error => error.Code == ValidationErrorCode.ExpectedTypeDifferent)); + Assert.That(2, Is.EqualTo(issues.Issues.Count()), "Expected 2 errors in the response"); } [Test] @@ -104,9 +104,9 @@ public void SimpleTypeValidationExtraProperty() string json = JsonConvert.SerializeObject(newObj, Settings); var issues = new IssueLogger(); - Assert.IsFalse(schema.ValidateJson(new JsonExample(json), issues, null, null)); - Assert.AreEqual(1, issues.Issues.Count()); - Assert.AreEqual(ValidationErrorCode.AdditionalPropertyDetected, issues.Issues.First().Code); + Assert.That(schema.ValidateJson(new JsonExample(json), issues, null, null), Is.False); + Assert.That(1, Is.EqualTo(issues.Issues.Count())); + Assert.That(ValidationErrorCode.AdditionalPropertyDetected, Is.EqualTo(issues.Issues.First().Code)); } [Test] @@ -125,9 +125,9 @@ public void SimpleTypeValidationMissingProperty() string json = JsonConvert.SerializeObject(newObj, Settings); var issues = new IssueLogger(); - Assert.IsFalse(schema.ValidateJson(new JsonExample(json), issues, null, null)); - Assert.AreEqual(1, issues.Issues.Count()); - Assert.AreEqual(ValidationErrorCode.RequiredPropertiesMissing, issues.Issues.First().Code); + Assert.That(schema.ValidateJson(new JsonExample(json), issues, null, null), Is.False); + Assert.That(1, Is.EqualTo(issues.Issues.Count())); + Assert.That(ValidationErrorCode.RequiredPropertiesMissing, Is.EqualTo(issues.Issues.First().Code)); } [Test] @@ -147,9 +147,9 @@ public void SimpleTypeValidationWrongTypeArray() string json = JsonConvert.SerializeObject(newObj, Settings); var issues = new IssueLogger(); - Assert.IsFalse(schema.ValidateJson(new JsonExample(json), issues, null, null)); - Assert.AreEqual(1, issues.Issues.Count()); - Assert.AreEqual(ValidationErrorCode.ExpectedNonArrayValue, issues.Issues.First().Code); + Assert.That(schema.ValidateJson(new JsonExample(json), issues, null, null), Is.False); + Assert.That(1, Is.EqualTo(issues.Issues.Count())); + Assert.That(ValidationErrorCode.ExpectedNonArrayValue, Is.EqualTo(issues.Issues.First().Code)); } [Test] @@ -161,7 +161,7 @@ public void TruncatedExampleWithRequiredPropertiesTest() var issues = new IssueLogger(); testFile.Scan(string.Empty, issues); - Assert.IsEmpty(issues.Issues.Where(x => x.IsError)); + Assert.That(issues.Issues.Where(x => x.IsError), Is.Empty); docSet.ResourceCollection.RegisterJsonResource(testFile.Resources.First()); @@ -172,9 +172,9 @@ public void TruncatedExampleWithRequiredPropertiesTest() testMethod.ValidateResponse(actualResponse, expectedResponse, null, issues); - Assert.AreEqual(1, issues.Errors.Count()); + Assert.That(1, Is.EqualTo(issues.Errors.Count())); var error = issues.Errors.First(); - Assert.AreEqual(ValidationErrorCode.RequiredPropertiesMissing, error.Code); + Assert.That(ValidationErrorCode.RequiredPropertiesMissing, Is.EqualTo(error.Code)); } [Test] @@ -186,7 +186,7 @@ public void TruncatedExampleSelectStatementOnChildren() var issues = new IssueLogger(); testFile.Scan(string.Empty, issues); - Assert.IsEmpty(issues.Issues.Where(x => x.IsError)); + Assert.That(issues.Issues.Where(x => x.IsError), Is.Empty); docSet.ResourceCollection.RegisterJsonResource(testFile.Resources.First()); @@ -197,7 +197,7 @@ public void TruncatedExampleSelectStatementOnChildren() testMethod.ValidateResponse(actualResponse, expectedResponse, null, issues); - Assert.AreEqual(0, issues.Errors.Count()); + Assert.That(0, Is.EqualTo(issues.Errors.Count())); } [Test] @@ -209,7 +209,7 @@ public void TruncatedExampleSelectStatementOnChildrenExpectFailure() var issues = new IssueLogger(); testFile.Scan(string.Empty, issues); - Assert.IsEmpty(issues.Issues.Where(x => x.IsError)); + Assert.That(issues.Issues.Where(x => x.IsError), Is.Empty); docSet.ResourceCollection.RegisterJsonResource(testFile.Resources.First()); @@ -220,8 +220,8 @@ public void TruncatedExampleSelectStatementOnChildrenExpectFailure() testMethod.ValidateResponse(actualResponse, expectedResponse, null, issues); - Assert.IsTrue(issues.Issues.Any(x => x.Code == ValidationErrorCode.RequiredPropertiesMissing), "Error with Code = RequiredPropertiesMissing"); - Assert.IsTrue( + Assert.That(issues.Issues.Any(x => x.Code == ValidationErrorCode.RequiredPropertiesMissing), "Error with Code = RequiredPropertiesMissing"); + Assert.That( issues.Issues.Any(x => x.Code == ValidationErrorCode.SkippedSimilarErrors), "Error with Code = SkippedSimilarErrors"); }