public void TestResourceTypeGetAttributeInfo(string name, bool attributeExists, IResourceType resourceType, string apiPropertyName, string clrPropertyName, JsonApiFramework.ServiceModel.IAttributeInfo expected) { this.Output.WriteLine("Test Name: {0}", name); this.Output.WriteLine(String.Empty); // Arrange // Act if (!attributeExists) { Assert.Throws <ServiceModelException>(() => resourceType.GetApiAttributeInfo(apiPropertyName)); Assert.Throws <ServiceModelException>(() => resourceType.GetClrAttributeInfo(clrPropertyName)); return; } var actualApiAttributeInfo = resourceType.GetApiAttributeInfo(apiPropertyName); var actualClrAttributeInfo = resourceType.GetClrAttributeInfo(clrPropertyName); // Assert AttributeInfoAssert.Equal(expected, actualApiAttributeInfo); AttributeInfoAssert.Equal(expected, actualClrAttributeInfo); }
public void TestResourceTypeTryGetAttributeInfo(string name, bool attributeExists, IResourceType resourceType, string apiPropertyName, string clrPropertyName, JsonApiFramework.ServiceModel.IAttributeInfo expected) { this.Output.WriteLine("Test Name: {0}", name); this.Output.WriteLine(String.Empty); // Arrange // Act JsonApiFramework.ServiceModel.IAttributeInfo actualApiAttributeInfo; var actualApiAttributeInfoExists = resourceType.TryGetApiAttributeInfo(apiPropertyName, out actualApiAttributeInfo); JsonApiFramework.ServiceModel.IAttributeInfo actualClrAttributeInfo; var actualClrAttributeInfoExists = resourceType.TryGetClrAttributeInfo(clrPropertyName, out actualClrAttributeInfo); // Assert if (!attributeExists) { Assert.False(actualApiAttributeInfoExists); Assert.Null(actualApiAttributeInfo); Assert.False(actualClrAttributeInfoExists); Assert.Null(actualClrAttributeInfo); return; } Assert.True(actualApiAttributeInfoExists); Assert.NotNull(actualApiAttributeInfo); AttributeInfoAssert.Equal(expected, actualApiAttributeInfo); Assert.True(actualClrAttributeInfoExists); Assert.NotNull(actualClrAttributeInfo); AttributeInfoAssert.Equal(expected, actualClrAttributeInfo); }