public void ComPluginRuntimeHandler_Test_WhenValidMethod_ExpectReturn() { //------------Setup for test-------------------------- var svc = CreatePluginService(); CreateComPluginSource(); var mock = new Mock <INamedPipeClientStreamWrapper>(); var memoryStream = new MemoryStream(); var list = new List <string>() { "Home" }; memoryStream.WriteByte(Encoding.ASCII.GetBytes(list.SerializeToJsonString(new KnownTypesBinder()))[0]); mock.Setup(wrapper => wrapper.GetInternalStream()).Returns(memoryStream); //------------Execute Test-------------------------- - var isolated = new ComPluginRuntimeHandler(mock.Object); var args = new ComPluginInvokeArgs { ClsId = adodbConnectionClassId, Fullname = svc.Namespace, Method = "ToString", Parameters = svc.Method.Parameters, Is32Bit = true }; var run = isolated.Test(args, out string outString); Assert.IsNotNull(run); Assert.IsNotNull(outString); }
public void ComPluginRuntimeHandler_FetchNamespaceListObject_WhenValidDll_ExpectNamespaces() { //------------Setup for test-------------------------- var source = CreateComPluginSource(); source.Is32Bit = true; //------------Execute Test--------------------------- var mock = new Mock <INamedPipeClientStreamWrapper>(); var memoryStream = new MemoryStream(); var list = new List <string>() { "Home" }; memoryStream.WriteByte(Encoding.ASCII.GetBytes(list.SerializeToJsonString(new KnownTypesBinder()))[0]); mock.Setup(wrapper => wrapper.GetInternalStream()).Returns(memoryStream); var isolated = new ComPluginRuntimeHandler(mock.Object); var result = isolated.FetchNamespaceListObject(source); //------------Assert Results------------------------- Assert.AreEqual(1, result.Count); var assemblyLocation = result[0].AssemblyLocation; Assert.IsTrue(string.IsNullOrEmpty(assemblyLocation)); }
public void ComPluginRuntimeHandler_Test_WhenInvalidMethod_ExpectNoReturn() { //------------Setup for test-------------------------- var svc = CreatePluginService(); CreateComPluginSource(); //------------Execute Test-------------------------- - var isolated = new ComPluginRuntimeHandler(); var args = new ComPluginInvokeArgs { ClsId = adodbConnectionClassId, Fullname = svc.Namespace, Method = "InvalidName", Parameters = svc.Method.Parameters }; var run = isolated.Test(args, out string outString); Assert.IsNotNull(run); Assert.IsNull(outString); }
public void ComPluginRuntimeHandler_ListMethods_WhenValidDll_ExpectListMethods_32bit() { //------------Setup for test-------------------------- var source = CreateComPluginSource(); source.Is32Bit = true; //------------Execute Test--------------------------- var mock = new Mock<INamedPipeClientStreamWrapper>(); var memoryStream = new MemoryStream(); var list = new List<string>() { "Home" }; memoryStream.WriteByte(Encoding.ASCII.GetBytes(list.SerializeToJsonString(new KnownTypesBinder()))[0]); mock.Setup(wrapper => wrapper.GetInternalStream()).Returns(memoryStream); var isolated = new ComPluginRuntimeHandler(mock.Object); var serviceMethodList = isolated.ListMethods(adodbConnectionClassId, true); //------------Assert Results------------------------- Assert.AreEqual(0, serviceMethodList.Count); }