public void GuidIdConvertFromString(StronglyTypedIDTypeConverterTestData <Guid> inTestData) { var converterGuid = TypeDescriptor.GetConverter(typeof(GuidStronglyTypedID)); if (inTestData.SerializedTestData.StartsWith("0000", System.StringComparison.CurrentCulture) || inTestData.SerializedTestData.StartsWith("01234", System.StringComparison.CurrentCulture)) { //var stronglyTypedID = SerializationFixtureSystemTextJson.Serializer.Deserialize<GuidStronglyTypedID>(inTestData.SerializedTestData); var stronglyTypedID = converterGuid.ConvertFrom(inTestData.SerializedTestData); stronglyTypedID.Should().BeOfType(typeof(GuidStronglyTypedID)); // GUIDS are random, two sets of test data have fixed, non-random guids, the rest are random stronglyTypedID.Should().Be(inTestData.InstanceTestData); } else { // No data for random guids } }
public void GuidIdConvertToString(StronglyTypedIDTypeConverterTestData <Guid> inTestData) { // ToDo low priority localize the unit test's exception's message if (inTestData == null) { throw new ArgumentNullException($"{nameof(inTestData)} argument should never be null"); } var converterGuid = TypeDescriptor.GetConverter(typeof(GuidStronglyTypedID)); // GUIDS are random, two sets of test data have fixed, non-random guids, the rest are random if (inTestData.SerializedTestData.StartsWith("0000", System.StringComparison.CurrentCulture) || inTestData.SerializedTestData.StartsWith("01234", System.StringComparison.CurrentCulture)) { converterGuid.ConvertTo(inTestData.InstanceTestData, typeof(string)).Should().Be(inTestData.SerializedTestData); } else { ((string)converterGuid.ConvertTo(inTestData.InstanceTestData, typeof(string))).Should().MatchRegex("^[0-9A-Fa-f]{8}-?([0-9A-Fa-f]{4}-?){3}[0-9A-Fa-f]{12}$"); } }
public void IntIdConvertToString(StronglyTypedIDTypeConverterTestData <int> inTestData) { // ToDo low priority localize the unit test's exception's message if (inTestData == null) { throw new ArgumentNullException($"{nameof(inTestData)} argument should never be null"); } var converterInt = TypeDescriptor.GetConverter(typeof(IntStronglyTypedID)); // two sets of test data have fixed, non-random Integers, the rest are random if (inTestData.SerializedTestData.Equals("0") || inTestData.SerializedTestData.Equals("1234567")) { converterInt.ConvertTo(inTestData.InstanceTestData, typeof(string)).Should().Be(inTestData.SerializedTestData); } else { // No test available for random integer } }
public void IntIdConvertFromString(StronglyTypedIDTypeConverterTestData <int> inTestData) { // ToDo low priority localize the unit test's exception's message if (inTestData == null) { throw new ArgumentNullException($"{nameof(inTestData)} argument should never be null"); } var converterInt = TypeDescriptor.GetConverter(typeof(IntStronglyTypedID)); if (inTestData.SerializedTestData.StartsWith("0000", System.StringComparison.CurrentCulture) || inTestData.SerializedTestData.StartsWith("01234", System.StringComparison.CurrentCulture)) { //var stronglyTypedID = SerializationFixtureSystemTextJson.Serializer.Deserialize<IntStronglyTypedID>(inTestData.SerializedTestData); var stronglyTypedID = converterInt.ConvertFrom(inTestData.SerializedTestData); stronglyTypedID.Should().BeOfType(typeof(IntStronglyTypedID)); // two sets of test data have fixed, non-random Integers, the rest are random stronglyTypedID.Should().Be(inTestData.InstanceTestData); } else { // No data for random Integers } }