public static void unrealoptiontypereference_is_initiated_as_expected_when_passed_an_option_type_reference_with_a_built_in_type_as_contained_type() { var optionTypeRaw = new FieldDefinitionRaw.OptionTypeRaw() { valueType = new TypeReferenceRaw() { sourceReference = new SourceReferenceRaw { line = "1", column = "1" }, builtInType = "float", userType = null } }; var containedTypeReference = new UnrealBuiltInTypeReference(optionTypeRaw.valueType); var unrealOptionTypeReference = new UnrealOptionTypeReference(containedTypeReference); Assert.That(unrealOptionTypeReference.UnderlyingCapitalisedName == "Float"); Assert.That(unrealOptionTypeReference.RequiredIncludes.Count == 1); Assert.That(unrealOptionTypeReference.RequiredIncludes.Contains("\"FloatOption.h\"")); Assert.That(unrealOptionTypeReference.UnderlyingQualifiedName == "float"); Assert.That(unrealOptionTypeReference.UnrealType == "UFloatOption*"); Assert.That(unrealOptionTypeReference.AssignUnderlyingValueToUnrealMemberVariable("TestField", "val") == "if (TestField == nullptr) { TestField = NewObject<UFloatOption>(this); } TestField->Init(val)"); Assert.That(unrealOptionTypeReference.ConvertUnderlyingValueToUnrealLocalVariable("val") == "NewObject<UFloatOption>()->Init(val)"); Assert.That(unrealOptionTypeReference.ConvertUnderlyingValueToUnrealMemberVariable("val") == "NewObject<UFloatOption>(this)->Init(val)"); Assert.That(unrealOptionTypeReference.ConvertUnrealValueToSnapshotValue("val") == "val->GetUnderlying()"); Assert.That(unrealOptionTypeReference.ConvertUnrealValueToUnderlyingValue("val") == "val->GetUnderlying()"); Assert.That(unrealOptionTypeReference.SnapshotType == "worker::Option<float>"); }
public static void unrealoptiontypereference_is_initiated_as_expected_when_passed_an_option_type_reference_with_an_user_type_as_contained_type() { var userTypeDefinition = GenerateTypeDefinition(); var unrealTypeDetails = new UnrealTypeDetails(userTypeDefinition, "TestType", new List <UnrealFieldDetails>(), null); var containedTypeReference = new UnrealUserTypeReference(unrealTypeDetails); var unrealOptionTypeReference = new UnrealOptionTypeReference(containedTypeReference); Assert.That(unrealOptionTypeReference.UnderlyingCapitalisedName == "ImprobableCodegenTestType"); Assert.That(unrealOptionTypeReference.RequiredIncludes.Count == 2); Assert.That(unrealOptionTypeReference.RequiredIncludes.Contains("\"ImprobableCodegenTestTypeOption.h\"")); Assert.That(unrealOptionTypeReference.RequiredIncludes.Contains("\"TestType.h\"")); Assert.That(unrealOptionTypeReference.UnderlyingQualifiedName == "improbable::codegen::TestType"); Assert.That(unrealOptionTypeReference.UnrealType == "UImprobableCodegenTestTypeOption*"); Assert.That(unrealOptionTypeReference.AssignUnderlyingValueToUnrealMemberVariable("TestField", "val") == "if (TestField == nullptr) { TestField = NewObject<UImprobableCodegenTestTypeOption>(this); } TestField->Init(val)"); Assert.That(unrealOptionTypeReference.ConvertUnderlyingValueToUnrealLocalVariable("val") == "NewObject<UImprobableCodegenTestTypeOption>()->Init(val)"); Assert.That(unrealOptionTypeReference.ConvertUnderlyingValueToUnrealMemberVariable("val") == "NewObject<UImprobableCodegenTestTypeOption>(this)->Init(val)"); Assert.That(unrealOptionTypeReference.ConvertUnrealValueToUnderlyingValue("val") == "val->GetUnderlying()"); Assert.That(unrealOptionTypeReference.ConvertUnrealValueToSnapshotValue("val") == "val->GetUnderlying()"); Assert.That(unrealOptionTypeReference.DefaultInitialisationString == "worker::Option<improbable::codegen::TestType>()"); Assert.That(unrealOptionTypeReference.SnapshotType == "worker::Option<improbable::codegen::TestType>"); }