/// <summary> /// Checks if struct must be with arguments, returns parsed object wwith arguments /// if type is foundand if conversion was successfull /// </summary> /// <param name="type">Type to check and parse</param> /// <param name="input">String to parse</param> /// <returns></returns> public object CheckIfStructMustHaveArgumentsAndReturnObject(Type type, string input) { if (type == typeof(MacAddress)) { var result = _genericInstanceCreator.TryCreateNewInstance <MacAddress>(input); if (result != default(MacAddress)) { return(result); } } if (type == typeof(IpV4Address)) { var result = _genericInstanceCreator.TryCreateNewInstance <IpV4Address>(input); if (result != default(IpV4Address)) { return(result); } } if (type == typeof(IpV4Fragmentation)) { var parameters = _moduleStructArguments.InputToParametersForIpV4Fragmentation(input); if (parameters != null) { return(_genericInstanceCreator.TryCreateNewInstance <IpV4Fragmentation>(parameters)); } } return(null); }
public void TryCreateNewInstance_CreateObjectWithoutParameters_ReturnsCreatedObject() { // Act var newObject = _target.TryCreateNewInstance <DummyLayerCreator>(); // Assert newObject.Should().BeOfType <DummyLayerCreator>(); newObject.Should().NotBeNull(); }