Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #30 string arguments not recognized in version 0.4.0 #31

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ static void Main(string[] args)

InterAppCommunication connector = new InterAppCommunication(command);
connector.ExecuteAsInteractiveCLI(args);

Console.ReadLine();
}
}
}
2 changes: 1 addition & 1 deletion src/InterAppConnector/Rules/DefaultRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public bool IsRuleEnabledInArgumentSetting(PropertyInfo property)
}
bool isEnumType = parameterType.IsEnum;
bool isValueTypeAndIsNotAStruct = parameterType.IsValueType && !StructHelper.IsStruct(parameterType);
return isEnumType || isValueTypeAndIsNotAStruct;
return isEnumType || isValueTypeAndIsNotAStruct || property.PropertyType == typeof(string);
}

public bool IsRuleEnabledInArgumentSetting(FieldInfo field)
Expand Down
1 change: 1 addition & 0 deletions tests/InterAppConnector.Test.Library/DataModels/Vehicle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public class Vehicle
// This format is used for example in Germany
[CustomInputString("llllnnnn")]
public LicensePlate LicensePlate { get; set; } = new LicensePlate("aaaa0000");
public string Manufacturer { get; set; } = "";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,15 @@ public void ExecuteAsBatch_WithEnumAndAliasCorrectParametersAndFieldName_ReturnS
dynamic parameters = new ExpandoObject();
((IDictionary<string, object>)parameters)[nameof(vehicle.Type)] = "motorcycle";
((IDictionary<string, object>)parameters)[nameof(vehicle.LicensePlate)] = "abcd1234";
((IDictionary<string, object>)parameters)[nameof(vehicle.Manufacturer)] = "UnitTest";

InterAppCommunication connector = new InterAppCommunication(command);
CommandResult<Vehicle> commandExecution = connector.ExecuteAsBatch<Vehicle>("testvehicle", parameters);

Assert.That(commandExecution.MessageStatus, Is.EqualTo(CommandExecutionMessageType.Success));
Assert.That(commandExecution.Message.Type, Is.EqualTo(VehicleType.Motorbike));
Assert.That(commandExecution.Message.LicensePlate.Plate, Is.EqualTo("abcd1234"));
Assert.That(commandExecution.Message.Manufacturer, Is.EqualTo("UnitTest"));
}

[Test]
Expand All @@ -149,13 +151,15 @@ public void ExecuteAsBatch_WithEnumAndAliasAndCorrectParameters_ReturnSuccessful
dynamic dynamic = new ExpandoObject();
dynamic.type = "motorcycle";
dynamic.licenseplate = "abcd1234";
dynamic.manufacturer = "UnitTest";

InterAppCommunication connector = new InterAppCommunication(command);
CommandResult<Vehicle> commandExecution = connector.ExecuteAsBatch<Vehicle>("testvehicle", dynamic);

Assert.That(commandExecution.MessageStatus, Is.EqualTo(CommandExecutionMessageType.Success));
Assert.That(commandExecution.Message.Type, Is.EqualTo(VehicleType.Motorbike));
Assert.That(commandExecution.Message.LicensePlate.Plate, Is.EqualTo("abcd1234"));
Assert.That(commandExecution.Message.Manufacturer, Is.EqualTo("UnitTest"));
}

/// llllnnnn
Expand All @@ -174,7 +178,7 @@ public void ExecuteAsBatch_WithEnumAndAliasAndWrongParameters_ReturnFailureObjec
};

Assert.That(connectorAction, Throws.InstanceOf<MissingMandatoryArgumentException>()
.And.Property("MissingParameters").Count.EqualTo(1));
.And.Property("MissingParameters").Count.EqualTo(2));
}

[Test]
Expand Down Expand Up @@ -311,7 +315,7 @@ public void ExecuteAsInteractiveCLI_WithEnumAndAliasAndCorrectParameters_ReturnS
{
CommandManager command = new CommandManager();
command.AddCommand<VehicleTestCommand, Vehicle>();
string[] arguments = { "testvehicle", "-type", "motorcycle", "-licenseplate", "abcd1234" };
string[] arguments = { "testvehicle", "-type", "motorcycle", "-licenseplate", "abcd1234", "-manufacturer", "UnitTest" };

Action connectorAction = () =>
{
Expand Down Expand Up @@ -544,13 +548,15 @@ public void CallSingleCommand_WithTestCommandConfiguredProperly_ReturnSuccessMes
dynamic dynamic = new ExpandoObject();
dynamic.type = "motorcycle";
dynamic.licenseplate = "abcd1234";
dynamic.manufacturer = "UnitTest";

InterAppCommunication connector = InterAppCommunication.CallSingleCommand<VehicleTestCommand, Vehicle>();
CommandResult<Vehicle> commandExecution = connector.ExecuteAsBatch<Vehicle>("testvehicle", dynamic);

Assert.That(commandExecution.MessageStatus, Is.EqualTo(CommandExecutionMessageType.Success));
Assert.That(commandExecution.Message.Type, Is.EqualTo(VehicleType.Motorbike));
Assert.That(commandExecution.Message.LicensePlate.Plate, Is.EqualTo("abcd1234"));
Assert.That(commandExecution.Message.Manufacturer, Is.EqualTo("UnitTest"));
}

[Test]
Expand Down Expand Up @@ -583,7 +589,7 @@ public void CallSingleCommand_WithEnumAndAliasAndWrongParameters_ReturnFailureOb
};

Assert.That(connectorAction, Throws.InstanceOf<MissingMandatoryArgumentException>()
.And.Property("MissingParameters").Count.EqualTo(1));
.And.Property("MissingParameters").Count.EqualTo(2));
}

[Test]
Expand Down
Loading