diff --git a/build/version.props b/build/version.props index 46a29c4..1ca9b67 100644 --- a/build/version.props +++ b/build/version.props @@ -1,7 +1,7 @@ 1.0.0 - preview-10020 + preview-10025 $(VersionPrefix)-$(VersionSuffix) $(VersionPrefix).0 $(VersionPrefix).0 diff --git a/src/Shriek.ServiceProxy.Abstractions/Shriek.ServiceProxy.Abstractions.csproj b/src/Shriek.ServiceProxy.Abstractions/Shriek.ServiceProxy.Abstractions.csproj index 394f643..25a66e1 100644 --- a/src/Shriek.ServiceProxy.Abstractions/Shriek.ServiceProxy.Abstractions.csproj +++ b/src/Shriek.ServiceProxy.Abstractions/Shriek.ServiceProxy.Abstractions.csproj @@ -8,7 +8,6 @@ - diff --git a/src/Shriek.ServiceProxy.Http/Shriek.ServiceProxy.Http.csproj b/src/Shriek.ServiceProxy.Http/Shriek.ServiceProxy.Http.csproj index daf4c03..93093e3 100644 --- a/src/Shriek.ServiceProxy.Http/Shriek.ServiceProxy.Http.csproj +++ b/src/Shriek.ServiceProxy.Http/Shriek.ServiceProxy.Http.csproj @@ -6,11 +6,11 @@ net461;netstandard2.0 - - + + - + diff --git a/src/Shriek.ServiceProxy.Tcp/Shriek.ServiceProxy.Tcp.csproj b/src/Shriek.ServiceProxy.Tcp/Shriek.ServiceProxy.Tcp.csproj index 26f97a3..01ed92d 100644 --- a/src/Shriek.ServiceProxy.Tcp/Shriek.ServiceProxy.Tcp.csproj +++ b/src/Shriek.ServiceProxy.Tcp/Shriek.ServiceProxy.Tcp.csproj @@ -9,7 +9,7 @@ - + diff --git a/src/Shriek/AppDomainExtensions.cs b/src/Shriek/AppDomainExtensions.cs index bb16b40..f239c23 100644 --- a/src/Shriek/AppDomainExtensions.cs +++ b/src/Shriek/AppDomainExtensions.cs @@ -36,9 +36,16 @@ public static IEnumerable GetExcutingAssemblies(this AppDomain @this) public static void UpdateExcutingAssemblies(this AppDomain @this) { - var assemblies = ReflectionUtil.GetAssemblies(new AssemblyFilter(@this.GetActualDomainPath())); + try + { + var assemblies = ReflectionUtil.GetAssemblies(new AssemblyFilter(@this.GetActualDomainPath())); - excutingAssembiles = @this.GetExcutingAssemblies().Union(assemblies).Union(new[] { Assembly.GetCallingAssembly(), Assembly.GetExecutingAssembly() }).Distinct(); + excutingAssembiles = @this.GetExcutingAssemblies().Union(assemblies) + .Union(new[] { Assembly.GetCallingAssembly(), Assembly.GetExecutingAssembly() }).Distinct(); + } + catch + { + } } } } \ No newline at end of file diff --git a/test/Shriek.Test/WebApiProxy/GetNotEncodingPlusTest.cs b/test/Shriek.Test/WebApiProxy/GetNotEncodingPlusTest.cs deleted file mode 100644 index c46502a..0000000 --- a/test/Shriek.Test/WebApiProxy/GetNotEncodingPlusTest.cs +++ /dev/null @@ -1,74 +0,0 @@ -using Castle.DynamicProxy; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; -using System; -using System.Net; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; -using Shriek.ServiceProxy.Abstractions.Attributes; -using Shriek.ServiceProxy.Http; -using Shriek.ServiceProxy.Http.ActionAttributes; -using Shriek.ServiceProxy.Http.ReturnAttributes; - -namespace Shriek.Test.WebApiProxy -{ - [TestClass] - public class GetNotEncodingPlusTest - { - private const string HelloWorld = "Hello world!"; - private Mock _invokation; - private Mock _client; - private IGreetings apiClient; - - [HttpHost("http://localhost")] - [Route("api")] - public interface IGreetings - { - [Route("{number:int}")] - [HttpGet] - [JsonReturn] - Task Hello(int number); - } - - [TestInitialize] - public void RunInvokation() - { - var httpResponseMessage = new HttpResponseMessage(HttpStatusCode.OK) - { - Content = new StringContent($"\"{HelloWorld}\"", Encoding.UTF8, "application/json") - }; - - _client = new Mock(); - _client.Setup(s => s.SendAsync(It.IsAny())).ReturnsAsync(httpResponseMessage); - - _invokation = new Mock(); - _invokation.SetupGet(i => i.Method).Returns(typeof(IGreetings).GetMethod("Hello")); - _invokation.SetupGet(i => i.Arguments).Returns(new object[] { 1555 }); - _invokation.SetupGet(i => i.Proxy).Returns(typeof(IGreetings)); - _invokation.SetupProperty(i => i.ReturnValue); - - //var client = new HttpApiClient(_client.Object); - //apiClient = client.GetHttpApi("http://localhost"); - //((IInterceptor)client).Intercept(_invokation.Object); - } - - [TestMethod] - public async Task VerifyReturnValue() - { - Assert.IsNotNull(_invokation.Object.ReturnValue); - var result = await ((Task)_invokation.Object.ReturnValue).ConfigureAwait(false); - - Assert.AreEqual(HelloWorld, result); - } - - [TestMethod] - public void VerifyRequest() - { - _client.Verify(c => - c.SendAsync(It.Is(m => - m.Method == HttpMethod.Get && - m.RequestUri == new Uri("http://localhost/api/1555")))); - } - } -} \ No newline at end of file diff --git a/test/Shriek.Test/WebApiProxy/GetPropertyTest.cs b/test/Shriek.Test/WebApiProxy/GetPropertyTest.cs deleted file mode 100644 index fe13548..0000000 --- a/test/Shriek.Test/WebApiProxy/GetPropertyTest.cs +++ /dev/null @@ -1,76 +0,0 @@ -using Castle.DynamicProxy; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; -using System; -using System.Net; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; -using Shriek.ServiceProxy.Abstractions.Attributes; -using Shriek.ServiceProxy.Http; -using Shriek.ServiceProxy.Http.ActionAttributes; - -namespace Shriek.Test.WebApiProxy -{ - [TestClass] - public class GetPropertyTest - { - private const string ResponseMessage = "Hello John Doe!"; - private Mock _invokation; - private Mock _client; - private IGreetings apiClient; - - public class Name - { - public string First { get; set; } - public string Last { get; set; } - } - - [HttpHost("http://localhost")] - public interface IGreetings - { - [HttpGet("/hello/{first}/{last}")] - Task Hello(Name name); - } - - [TestInitialize] - public void RunInvokation() - { - var httpResponseMessage = new HttpResponseMessage(HttpStatusCode.OK) - { - Content = new StringContent($"\"{ResponseMessage}\"", Encoding.UTF8, "application/json") - }; - - _client = new Mock(); - _client.Setup(s => s.SendAsync(It.IsAny())).ReturnsAsync(httpResponseMessage); - - _invokation = new Mock(); - _invokation.SetupGet(i => i.Method).Returns(typeof(IGreetings).GetMethod("Hello")); - _invokation.SetupGet(i => i.Arguments).Returns(new object[] { new Name { First = "John", Last = "Doe" } }); - _invokation.SetupProperty(i => i.ReturnValue); - _invokation.SetupGet(i => i.Proxy).Returns(typeof(IGreetings)); - - //var client = new HttpApiClient(_client.Object); - //apiClient = client.GetHttpApi("http://localhost"); - //((IInterceptor)client).Intercept(_invokation.Object); - } - - [TestMethod] - public async Task VerifyReturnValue() - { - Assert.IsNotNull(_invokation.Object.ReturnValue); - var result = await ((Task)_invokation.Object.ReturnValue).ConfigureAwait(false); - - Assert.AreEqual(ResponseMessage, result); - } - - [TestMethod] - public void VerifyRequest() - { - _client.Verify(c => - c.SendAsync(It.Is(m => - m.Method == HttpMethod.Get && - m.RequestUri == new Uri("http://localhost/hello/John/Doe")))); - } - } -} \ No newline at end of file diff --git a/test/Shriek.Test/WebApiProxy/GetStringTest.cs b/test/Shriek.Test/WebApiProxy/GetStringTest.cs deleted file mode 100644 index 108600b..0000000 --- a/test/Shriek.Test/WebApiProxy/GetStringTest.cs +++ /dev/null @@ -1,70 +0,0 @@ -using Castle.DynamicProxy; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; -using System; -using System.Net; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; -using Shriek.ServiceProxy.Abstractions.Attributes; -using Shriek.ServiceProxy.Http; -using Shriek.ServiceProxy.Http.ActionAttributes; - -namespace Shriek.Test.WebApiProxy -{ - [TestClass] - public class GetStringTest - { - private const string HelloWorld = "Hello world!"; - private Mock _invokation; - private Mock _client; - private IGreetings apiClient; - - [HttpHost("http://localhost")] - public interface IGreetings - { - [HttpGet("/hello/{name}")] - Task Hello(string name); - } - - [TestInitialize] - public void RunInvokation() - { - var httpResponseMessage = new HttpResponseMessage(HttpStatusCode.OK) - { - Content = new StringContent($"\"{HelloWorld}\"", Encoding.UTF8, "application/json") - }; - - _client = new Mock(); - _client.Setup(s => s.SendAsync(It.IsAny())).ReturnsAsync(httpResponseMessage); - - _invokation = new Mock(); - _invokation.SetupGet(i => i.Method).Returns(typeof(IGreetings).GetMethod("Hello")); - _invokation.SetupGet(i => i.Arguments).Returns(new object[] { "World" }); - _invokation.SetupGet(i => i.Proxy).Returns(typeof(IGreetings)); - _invokation.SetupProperty(i => i.ReturnValue); - - //var client = new HttpApiClient(_client.Object); - //apiClient = client.GetHttpApi("http://localhost"); - //((IInterceptor)client).Intercept(_invokation.Object); - } - - [TestMethod] - public async Task VerifyReturnValue() - { - Assert.IsNotNull(_invokation.Object.ReturnValue); - var result = await ((Task)_invokation.Object.ReturnValue).ConfigureAwait(false); - - Assert.AreEqual(HelloWorld, result); - } - - [TestMethod] - public void VerifyRequest() - { - _client.Verify(c => - c.SendAsync(It.Is(m => - m.Method == HttpMethod.Get && - m.RequestUri == new Uri("http://localhost/hello/World")))); - } - } -} \ No newline at end of file diff --git a/test/Shriek.Test/WebApiProxy/PostWithUriAndBodyTest.cs b/test/Shriek.Test/WebApiProxy/PostWithUriAndBodyTest.cs deleted file mode 100644 index 12a4249..0000000 --- a/test/Shriek.Test/WebApiProxy/PostWithUriAndBodyTest.cs +++ /dev/null @@ -1,97 +0,0 @@ -using Castle.DynamicProxy; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; -using System; -using System.Net; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; -using Shriek.ServiceProxy.Abstractions.Attributes; -using Shriek.ServiceProxy.Http; -using Shriek.ServiceProxy.Http.ActionAttributes; -using Shriek.ServiceProxy.Http.ParameterAttributes; - -namespace Shriek.Test.WebApiProxy -{ - [TestClass] - public class PostWithUriAndBodyTest - { - private Mock _invokation; - private Mock _client; - - private ITestInterface apiClient; - - [HttpHost("http://localhost")] - public interface ITestInterface - { - [HttpPost("/find/{type}")] - Task Find(string type, [JsonContent] TestRequest request); - } - - public class TestRequest - { - public string Query { get; set; } - } - - public class TestResponse - { - public string Name { get; set; } - public int Age { get; set; } - } - - [TestInitialize] - public void RunInvokation() - { - var httpResponseMessage = new HttpResponseMessage(HttpStatusCode.OK) - { - Content = new StringContent("{\"Name\": \"John Doe\", \"Age\":47}", Encoding.UTF8, "application/json") - }; - - _client = new Mock(); - _client.Setup(s => s.SendAsync(It.IsAny())).ReturnsAsync(httpResponseMessage); - - _invokation = new Mock(); - _invokation.SetupGet(i => i.Method).Returns(typeof(ITestInterface).GetMethod(nameof(ITestInterface.Find))); - _invokation.SetupGet(i => i.Arguments).Returns(new object[] { "theType", new TestRequest { Query = "name is SomeValue" } }); - _invokation.SetupGet(i => i.Proxy).Returns(typeof(ITestInterface)); - _invokation.SetupProperty(i => i.ReturnValue); - - //var client = new HttpApiClient(_client.Object); - //apiClient = client.GetHttpApi("http://localhost"); - //((IInterceptor)client).Intercept(_invokation.Object); - } - - [TestMethod] - public async Task VerifyReturnValue() - { - var result = await apiClient.Find("theType", new TestRequest() - { - Query = "name is SomeValue" - }); - - Assert.IsNotNull(result); - Assert.AreEqual("John Doe", result.Name); - Assert.AreEqual(47, result.Age); - } - - [TestMethod] - public void VerifyRequest() - { - _client.Verify(c => - c.SendAsync(It.Is(m => - m.Method == HttpMethod.Post && - m.RequestUri == new Uri("http://localhost/find/theType") && - VerifyContent(m.Content)))); - } - - private static bool VerifyContent(HttpContent content) - { - Assert.AreEqual("application/json", content.Headers.ContentType.MediaType); - - var body = content.ReadAsStringAsync().GetAwaiter().GetResult(); - Assert.AreEqual("{\"Query\":\"name is SomeValue\"}", body); - - return true; - } - } -} \ No newline at end of file