public void Contraints_Should_Be_Empty_List_Upon_Initialization() { // Act var toscaPropertyDefinition = new ToscaProperty(); // Assert toscaPropertyDefinition.Constraints.Should().BeEmpty(); }
public void Validation_Valid_Values_Of_Custom_Data_Type_Should_Pass_If_Proper_Parser_Registered() { // Arrange var toscaMetadata = new ToscaMetadata { CreatedBy = "Anonymous", CsarVersion = new Version(1, 1, 2), EntryDefinitions = "definitions.yaml", ToscaMetaFileVersion = new Version(1, 0) }; var cloudServiceArchive = new ToscaCloudServiceArchive(toscaMetadata); var definitions = new ToscaServiceTemplate { ToscaDefinitionsVersion = "tosca_simple_yaml_1_0" }; var complexDataType = new ToscaDataType(); var realProperty = new ToscaProperty { Type = "float" }; complexDataType.Properties.Add("real", realProperty); complexDataType.Properties.Add("imaginary", new ToscaProperty { Type = "float" }); definitions.DataTypes.Add("tosca.standard.Complex", complexDataType); var complexProperty = new ToscaProperty { Type = "tosca.standard.Complex" }; complexProperty.Constraints.Add(new Dictionary <string, object> { { "valid_values", new List <object> { "1 + 1i" } } }); var basicNodetype = new ToscaNodeType(); basicNodetype.Properties.Add("complex", complexProperty); definitions.NodeTypes.Add("basic", basicNodetype); DependencyResolver.Current.RegisterDataTypeConverter(new CustomDataTypeConverter()); cloudServiceArchive.AddToscaServiceTemplate("definitions.yaml", definitions); // Act List <ValidationResult> results; cloudServiceArchive.TryValidate(out results); // Assert results.Should().BeEmpty(); }
public void Exception_Should_Be_Thrown_When_Parser_For_Custom_Data_Type_Not_Defined() { // Arrange var toscaMetadata = new ToscaMetadata { CreatedBy = "Anonymous", CsarVersion = new Version(1, 1, 2), EntryDefinitions = "definitions.yaml", ToscaMetaFileVersion = new Version(1, 0) }; var cloudServiceArchive = new ToscaCloudServiceArchive(toscaMetadata); var definitions = new ToscaServiceTemplate { ToscaDefinitionsVersion = "tosca_simple_yaml_1_0" }; var complexDataType = new ToscaDataType(); var realProperty = new ToscaProperty { Type = "float" }; complexDataType.Properties.Add("real", realProperty); complexDataType.Properties.Add("imaginary", new ToscaProperty { Type = "float" }); definitions.DataTypes.Add("tosca.standard.Complex", complexDataType); var complexProperty = new ToscaProperty { Type = "tosca.standard.Complex" }; complexProperty.Constraints.Add(new Dictionary <string, object> { { "valid_values", new List <object> { "1 + 1i" } } }); var basicNodetype = new ToscaNodeType(); basicNodetype.Properties.Add("complex", complexProperty); definitions.NodeTypes.Add("basic", basicNodetype); cloudServiceArchive.AddToscaServiceTemplate("definitions.yaml", definitions); // Act List <ValidationResult> results; Action action = () => cloudServiceArchive.TryValidate(out results); // Assert action.ShouldThrow <ToscaDataTypeParserNotFoundException>() .WithMessage("Parser for data type 'tosca.standard.Complex' nod found."); }
public void StringValue_Should_Be_Empty_When_Default_Is_Null() { var toscaPropertyDefinition = new ToscaProperty {Default = null}; toscaPropertyDefinition.StringValue.Should().BeEmpty(); }
public void StringValue_Should_Be_Number_As_String_When_Default_Is_Integer() { var toscaPropertyDefinition = new ToscaProperty {Default = 23}; toscaPropertyDefinition.StringValue.Should().Be("23"); }