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)); } 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 GuidIdConvertToString(StronglyTypedIdTypeConverterTestData <Guid> inTestData) { // ToDo low priority localize the unit test's exception's message if (inTestData == null) { throw new ArgumentNullException(nameof(inTestData)); } 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 GuidIdConvertFromString(StronglyTypedIdTypeConverterTestData <Guid> inTestData) { if (inTestData == null) { throw new ArgumentNullException(nameof(inTestData)); } var converterGuid = TypeDescriptor.GetConverter(typeof(GuidStronglyTypedId)); if (inTestData.SerializedTestData.StartsWith("0000", System.StringComparison.CurrentCulture) || inTestData.SerializedTestData.StartsWith("01234", System.StringComparison.CurrentCulture)) { //var stronglyTypedId = SerializationSystemTextJsonFixture.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 IntIdConvertFromString(StronglyTypedIdTypeConverterTestData <int> inTestData) { // ToDo low priority localize the unit test's exception's message if (inTestData == null) { throw new ArgumentNullException(nameof(inTestData)); } var converterInt = TypeDescriptor.GetConverter(typeof(IntStronglyTypedId)); if (inTestData.SerializedTestData.StartsWith("0000", System.StringComparison.CurrentCulture) || inTestData.SerializedTestData.StartsWith("01234", System.StringComparison.CurrentCulture)) { //var stronglyTypedId = SerializationSystemTextJsonFixture.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 } }