コード例 #1
0
        public void Set_Primitive_Uri_Success()
        {
            TypeAdapter.ClearCache();
            TypeAdapterConfig.GlobalSettings.PrimitiveTypes.Add(typeof(Uri));

            var sourceUri = new Uri("http://example.com");
            var targetUri = TypeAdapter.Adapt <Uri, Uri>(sourceUri);

            targetUri.ShouldEqual(sourceUri);
        }
コード例 #2
0
        public void No_Primitive_Uri_Should_Throw()
        {
            TypeAdapter.ClearCache();
            var sourceUri = new Uri("http://example.com");

            var exception = Assert.Throws <ArgumentNullException>(() => TypeAdapter.Adapt <Uri, Uri>(sourceUri));

            Console.WriteLine(exception.Message);

            exception.ParamName.ShouldEqual("con");
        }