public void Parse_EnumWithDescription_ParsesCorrectly() { var template = new EnumGraphTypeTemplate(typeof(EnumWithDescription)); template.Parse(); template.ValidateOrThrow(); Assert.AreEqual("Enum Description", template.Description); }
public void Parse_EnumWithGraphName_ParsesCorrectly() { var template = new EnumGraphTypeTemplate(typeof(EnumWithGraphName)); template.Parse(); template.ValidateOrThrow(); Assert.AreEqual("ValidGraphName", template.Name); }
public void Parse_EnumWithValueWithGraphName_ButGraphNameIsInvalid_ThrowsException() { var template = new EnumGraphTypeTemplate(typeof(EnumWithValueWithGraphNameButGraphNameIsInvalid)); template.Parse(); Assert.Throws <GraphTypeDeclarationException>(() => { template.ValidateOrThrow(); }); }
public void Parse_EnumWithDuplciateValuesFromComposite_ThrowsException() { var template = new EnumGraphTypeTemplate(typeof(EnumWithDuplicateValuesFromComposite)); template.Parse(); Assert.Throws <GraphTypeDeclarationException>(() => { template.ValidateOrThrow(); }); }
public void Parse_EnumWithValueWithGraphName_ParsesCorrectly() { var template = new EnumGraphTypeTemplate(typeof(EnumWithValueWithGraphName)); template.Parse(); template.ValidateOrThrow(); Assert.IsTrue(template.Values.Any(x => x.Name == "Value1")); Assert.IsTrue(template.Values.Any(x => x.Name == "AnotherName")); Assert.IsTrue(template.Values.All(x => x.Name != "Value2")); }
public void Parse_EnumWithDescriptionOnValues_ParsesCorrectly() { var template = new EnumGraphTypeTemplate(typeof(EnumWithDescriptionOnValues)); template.Parse(); template.ValidateOrThrow(); Assert.IsTrue(template.Values.Any(x => x.Name == "Value1" && x.Description == null)); Assert.IsTrue(template.Values.Any(x => x.Name == "Value2" && x.Description == "Value2 Description")); Assert.IsTrue(template.Values.Any(x => x.Name == "Value3" && x.Description == null)); Assert.IsTrue(template.Values.Any(x => x.Name == "Value4" && x.Description == "Value4 Description")); }
public void Parse_UnsignedEnum_CompleteKeySpace_ParsesCorrectly() { // the enum defines EVERY value for its key space // ensure it parses var template = new EnumGraphTypeTemplate(typeof(EnumCompleteByte)); template.Parse(); template.ValidateOrThrow(); // 0 => 255 Assert.AreEqual(256, template.Values.Count); }
public void Parse_EnsureEnumsOfUnSignedValues(Type type) { var template = new EnumGraphTypeTemplate(type); template.Parse(); template.ValidateOrThrow(); Assert.AreEqual(3, template.Values.Count); Assert.IsTrue(template.Values.Any(x => x.Name == "Value1")); Assert.IsTrue(template.Values.Any(x => x.Name == "Value2")); Assert.IsTrue(template.Values.Any(x => x.Name != "Value3")); }
public void Parse_EnumWithNonIntBase_ParsesCorrectly() { var template = new EnumGraphTypeTemplate(typeof(EnumFromUInt)); template.Parse(); template.ValidateOrThrow(); Assert.AreEqual(3, template.Values.Count); Assert.IsTrue(template.Values.Any(x => x.Name == "Value1")); Assert.IsTrue(template.Values.Any(x => x.Name == "Value2")); Assert.IsTrue(template.Values.Any(x => x.Name != "Value3")); }
public void Parse_SimpleEnum_AllDefault_ParsesCorrectly() { var template = new EnumGraphTypeTemplate(typeof(SimpleEnum)); template.Parse(); template.ValidateOrThrow(); Assert.AreEqual($"{Constants.Routing.ENUM_ROOT}/{nameof(SimpleEnum)}", template.Route.Path); Assert.AreEqual(nameof(SimpleEnum), template.Name); Assert.AreEqual(null, template.Description); Assert.AreEqual(1, template.Values.Count()); Assert.AreEqual("Value1", template.Values[0].Name); Assert.AreEqual(null, template.Values[0].Description); }
public void Parse_DeprecatedValue_ParsesCorrectly() { var template = new EnumGraphTypeTemplate(typeof(DeprecatedValueEnum)); template.Parse(); template.ValidateOrThrow(); Assert.AreEqual(2, template.Values.Count()); var val1 = template.Values.FirstOrDefault(x => x.Name == nameof(DeprecatedValueEnum.Value1)); var val2 = template.Values.FirstOrDefault(x => x.Name == nameof(DeprecatedValueEnum.Value2)); Assert.IsNotNull(val1); Assert.IsFalse(val1.IsDeprecated); Assert.IsNull(val1.DeprecationReason); Assert.IsNotNull(val2); Assert.IsTrue(val2.IsDeprecated); Assert.AreEqual("Because", val2.DeprecationReason); }