コード例 #1
0
        public void PluginRuntimeHandler_ListNamespaces_WhenNullLocation_ExpectException()
        {
            //------------Setup for test--------------------------
            var pluginRuntimeHandler = new PluginRuntimeHandler();

            //------------Execute Test---------------------------
            pluginRuntimeHandler.ListNamespaces(null, "Foo");
        }
コード例 #2
0
        public void PluginRuntimeHandler_ValidatePlugin_WhenNullDll_ExpectErrorMessage()
        {
            //------------Setup for test--------------------------
            var pluginRuntimeHandler = new PluginRuntimeHandler();

            //------------Execute Test---------------------------
            pluginRuntimeHandler.ValidatePlugin(null);
        }
コード例 #3
0
        public void PluginRuntimeHandler_FetchNamespaceListObject_WhenNullDll_ExpectException()
        {
            //------------Setup for test--------------------------
            var pluginRuntimeHandler = new PluginRuntimeHandler();

            //------------Execute Test---------------------------
            pluginRuntimeHandler.FetchNamespaceListObject(null);
        }
コード例 #4
0
        public void PluginRuntimeHandler_FetchNamespaceListObject_WhenNullLocationAndInvalidSourceID_ExpectException()
        {
            //------------Setup for test--------------------------
            var pluginRuntimeHandler = new PluginRuntimeHandler();
            var source = CreatePluginSource(true);

            //------------Execute Test---------------------------
            pluginRuntimeHandler.FetchNamespaceListObject(source);
        }
コード例 #5
0
        public void PluginRuntimeHandler_ListNamespaces_WhenInvalidLocation_ExpectNoResults()
        {
            //------------Setup for test--------------------------
            var pluginRuntimeHandler = new PluginRuntimeHandler();

            //------------Execute Test---------------------------
            var result = pluginRuntimeHandler.ListNamespaces("z:\foo\asm.dll", "Foo");

            Assert.IsFalse(result.Any());
        }
コード例 #6
0
        public void PluginRuntimeHandler_ValidatePlugin_WhenInvalidGacDll_ExpectErrorMessage()
        {
            //------------Setup for test--------------------------
            var pluginRuntimeHandler = new PluginRuntimeHandler();

            //------------Execute Test---------------------------
            var result = pluginRuntimeHandler.ValidatePlugin("GAC:mscorlib_foo, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");

            //------------Assert Results-------------------------
            StringAssert.Contains(result, "Could not load file or assembly 'mscorlib_foo");
        }
コード例 #7
0
        public void PluginRuntimeHandler_ValidatePlugin_WhenGacDll_ExpectBlankMessage()
        {
            //------------Setup for test--------------------------
            var pluginRuntimeHandler = new PluginRuntimeHandler();

            //------------Execute Test---------------------------
            var result = pluginRuntimeHandler.ValidatePlugin("GAC:mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");

            //------------Assert Results-------------------------
            StringAssert.Contains(result, string.Empty);
        }
コード例 #8
0
        public void PluginRuntimeHandler_FetchNamespaceListObject_WhenValidDll_ExpectNamespaces()
        {
            //------------Setup for test--------------------------
            var pluginRuntimeHandler = new PluginRuntimeHandler();
            var source = CreatePluginSource();

            //------------Execute Test---------------------------
            var result = pluginRuntimeHandler.FetchNamespaceListObject(source);

            //------------Assert Results-------------------------
            Assert.IsTrue(result.Count > 0);
        }
コード例 #9
0
        public void PluginRuntimeHandler_Run_WhenNullLocation_ExpectException()
        {
            //------------Setup for test--------------------------
            var svc = CreatePluginService();
            var pluginRuntimeHandler = new PluginRuntimeHandler();
            PluginInvokeArgs args    = new PluginInvokeArgs {
                AssemblyLocation = null, AssemblyName = "Foo", Fullname = svc.Namespace, Method = svc.Method.Name, Parameters = svc.Method.Parameters
            };

            //------------Execute Test---------------------------
            pluginRuntimeHandler.Run(args);
        }
コード例 #10
0
        public void PluginRuntimeHandler_ListNamespaces_WhenValidLocation_ExpectNamespaces()
        {
            //------------Setup for test--------------------------
            var pluginRuntimeHandler = new PluginRuntimeHandler();
            var source = CreatePluginSource();

            //------------Execute Test---------------------------
            var result = pluginRuntimeHandler.ListNamespaces(source.AssemblyLocation, "Foo");

            //------------Assert Results-------------------------
            Assert.IsTrue(result.Any());
        }
コード例 #11
0
        public void PluginRuntimeHandler_ValidatePlugin_WhenNotADll_ExpectErrorMessage()
        {
            //------------Setup for test--------------------------
            var pluginRuntimeHandler = new PluginRuntimeHandler();
            var source = CreatePluginSource();

            //------------Execute Test---------------------------
            var result = pluginRuntimeHandler.ValidatePlugin(source.AssemblyLocation + ".foo");

            //------------Assert Results-------------------------
            StringAssert.Contains(result, "Not a Dll file");
        }
コード例 #12
0
        public void PluginRuntimeHandler_ValidatePlugin_WhenValidDll_ExpectBlankMessage()
        {
            //------------Setup for test--------------------------
            var pluginRuntimeHandler = new PluginRuntimeHandler();
            var source = CreatePluginSource();

            //------------Execute Test---------------------------
            var result = pluginRuntimeHandler.ValidatePlugin(source.AssemblyLocation);

            //------------Assert Results-------------------------
            StringAssert.Contains(result, string.Empty);
        }
コード例 #13
0
        public void PluginRuntimeHandler_Run_WhenHasInnerError_ExpectInerErrors()
        {
            //------------Setup for test--------------------------

            var type = typeof(Human);
            var svc  = CreatePluginService(new List <IDev2MethodInfo> {
                new Dev2MethodInfo {
                    Method = "set_Name", Parameters = new List <IMethodParameter>()
                    {
                        new ConstructorParameter()
                        {
                            Name = "value", Value = "Micky", TypeName = typeof(string).FullName, IsRequired = true
                        }
                    }
                }
            }, type, new ServiceConstructor());
            //------------Execute Test---------------------------
            var      mock = new Mock <IAssemblyLoader>();
            Assembly loadedAssembly;

            var handler = new PluginRuntimeHandler(mock.Object);

            var pluginInvokeArgs = new PluginInvokeArgs
            {
                MethodsToRun      = svc.MethodsToRun,
                PluginConstructor = new PluginConstructor
                {
                    ConstructorName = svc.Constructor.Name,
                    Inputs          = new List <IConstructorParameter>(),
                },
                AssemblyLocation = type.Assembly.Location,
                AssemblyName     = type.Assembly.FullName,
                Fullname         = type.FullName,
            };
            var pluginExecutionDto = new PluginExecutionDto(String.Empty)
            {
                Args = pluginInvokeArgs
            };
            var exception = new Exception("err", new Exception());

            mock.Setup(loader => loader.TryLoadAssembly(It.IsAny <string>(), It.IsAny <string>(), out loadedAssembly))
            .Throws(exception);

            var    dev2MethodInfo = pluginInvokeArgs.MethodsToRun.First();
            string stringOBj;
            var    run = handler.Run(dev2MethodInfo, pluginExecutionDto, out stringOBj);

            Assert.IsNotNull(run);
            Assert.IsTrue(run.HasError);
            Assert.IsFalse(string.IsNullOrEmpty(run.ErrorMessage));
        }
コード例 #14
0
        public void FetchNamespaceListObjectWithJsonObjects_GivenThrowsBadFormatExceptionError_ShouldRethrowBadFormatException()
        {
            //---------------Set up test pack-------------------
            var source = CreatePluginSource(typeof(DummyClassForPluginTest));
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var      mockAssemblyLoader = new Mock <IAssemblyLoader>();
            Assembly assembly;

            mockAssemblyLoader.Setup(loader => loader.TryLoadAssembly(It.IsAny <string>(), It.IsAny <string>(), out assembly))
            .Throws(new BadImageFormatException());
            var pluginRuntimeHandler = new PluginRuntimeHandler(mockAssemblyLoader.Object);

            //---------------Test Result -----------------------
            pluginRuntimeHandler.FetchNamespaceListObjectWithJsonObjects(source);
        }
コード例 #15
0
        public void PluginRuntimeHandler_AdjustPluginResult_WhenClassIsSealed_ExpectRunsCorrectly()
        {
            //------------Setup for test--------------------------

            var type = typeof(PluginRuntimeHandler);

            var    methodInfo = type.GetMethod("AdjustPluginResult", BindingFlags.NonPublic | BindingFlags.Instance);
            var    human      = new Human();
            var    memberInfo = human.GetType().GetMethod("ToString", BindingFlags.Instance | BindingFlags.Public);
            object result     = "string";
            //------------Execute Test---------------------------
            var runtimeHandler = new PluginRuntimeHandler();
            var resultAdgusted = methodInfo.Invoke(runtimeHandler, new[] { result, memberInfo });

            Assert.AreEqual("<PrimitiveReturnValue>string</PrimitiveReturnValue>", resultAdgusted);
        }
コード例 #16
0
        public void PluginRuntimeHandler_Test_WhenValid_ExpectRunsCorrectly()
        {
            //------------Setup for test--------------------------

            var type = typeof(Human);
            var svc  = CreatePluginService(new List <IDev2MethodInfo> {
                new Dev2MethodInfo {
                    Method = "EmptyIsNullTest", Parameters = new List <IMethodParameter>()
                }
            }, type, new ServiceConstructor());
            //------------Execute Test---------------------------
            var isolated = new PluginRuntimeHandler();

            var pluginInvokeArgs = new PluginInvokeArgs
            {
                MethodsToRun      = svc.MethodsToRun,
                PluginConstructor = new PluginConstructor
                {
                    ConstructorName = svc.Constructor.Name,
                    Inputs          = new List <IConstructorParameter>(),
                },
                AssemblyLocation = type.Assembly.Location,
                AssemblyName     = type.Assembly.FullName,
                Fullname         = type.FullName,
                Parameters       = new List <MethodParameter>()
                {
                    new MethodParameter()
                    {
                        Name     = "value",
                        TypeName = typeof(string).FullName,
                        Value    = "a"
                    }
                },

                Method = "EmptyIsNullTest"
            };
            string jresult;
            var    instance = isolated.Test(pluginInvokeArgs, out jresult);

            Assert.IsTrue(!string.IsNullOrEmpty(jresult));
            var count = instance.DataSourceShapes.Count;

            Assert.AreEqual(1, count);
        }
コード例 #17
0
        public void GetPropertiesJObject_GivenOracleCommand_ShouldRetunWithTwoProperties()
        {
            //---------------Set up test pack-------------------
            var runtimeHandler = new PluginRuntimeHandler();
            var type           = new Warewolf.Testing.PrivateObject(runtimeHandler);

#pragma warning disable 618
            var type1 = typeof(OracleCommand);
#pragma warning restore 618
            //---------------Assert Precondition----------------
            var invokeStatic = type.Invoke("GetPropertiesJObject", true, type1);
            //---------------Execute Test ----------------------
            var jObject = invokeStatic as JObject;
            //---------------Test Result -----------------------
            Assert.IsNotNull(jObject);
            var hasValues = jObject.HasValues;
            Assert.IsTrue(hasValues);
            Assert.AreEqual(8, jObject.Count);
        }
コード例 #18
0
        public void GetPropertiesJObject_GivenOracleCommand_ShouldHaveCorrectShape()
        {
            //---------------Set up test pack-------------------
            var runtimeHandler = new PluginRuntimeHandler();
            var type           = new Warewolf.Testing.PrivateObject(runtimeHandler);

#pragma warning disable 618
            var type1 = typeof(OracleCommand);
#pragma warning restore 618
            //---------------Assert Precondition----------------
            var invokeStatic = type.Invoke("GetPropertiesJObject", true, type1);
            //---------------Execute Test ----------------------
            var jObject = invokeStatic as JObject;
            Assert.IsNotNull(jObject);
            var hasValues = jObject.HasValues;
            Assert.IsTrue(hasValues);
            Assert.AreEqual(8, jObject.Count);
            //---------------Test Result -----------------------
            const string str = "{\"CommandText\":\"\",\"CommandTimeout\":\"\",\"CommandType\":\"\",\"Connection\":\"\",\"DesignTimeVisible\":\"\",\"Transaction\":\"\",\"UpdatedRowSource\":\"\",\"Site\":\"\"}";
            var          s   = jObject.ToString(Formatting.None);
            Assert.AreEqual(str, s);
        }
コード例 #19
0
        public void PluginRuntimeHandler_Run_WhenValidLocation_ExpectResult()
        {
            //------------Setup for test--------------------------
            var svc    = CreatePluginService();
            var source = CreatePluginSource();
            var pluginRuntimeHandler = new PluginRuntimeHandler();
            PluginInvokeArgs args    = new PluginInvokeArgs {
                AssemblyLocation = source.AssemblyLocation, AssemblyName = "Foo", Fullname = svc.Namespace, Method = svc.Method.Name, Parameters = svc.Method.Parameters
            };

            //------------Execute Test---------------------------
            var result     = pluginRuntimeHandler.Run(args);
            var castResult = result as DummyClassForPluginTest;

            //------------Assert Results-------------------------
            if (castResult != null)
            {
                StringAssert.Contains(castResult.Name, "test data");
            }
            else
            {
                Assert.Fail("Failed Conversion for Assert");
            }
        }