Exemplo n.º 1
0
        public void Instantiate_NotImplementingInterface_NotInstantiated()
        {
            var factory = new CustomCommandFactoryProxy();

            void instantiate() => factory.Instantiate
            (
                Mock.Of <ICustomCommandArgs>(x =>
                                             x.AssemblyPath == new LiteralScalarResolver <string>(".") &&
                                             x.TypeName == new LiteralScalarResolver <string>(this.GetType().Name) &&
                                             x.Parameters == null
                                             )
            );

            Assert.Throws <NBiException>(instantiate);
        }
Exemplo n.º 2
0
        public void Instantiate_NotExistingNamespaceType_NotInstantiated()
        {
            var factory = new CustomCommandFactoryProxy();

            void instantiate() => factory.Instantiate
            (
                Mock.Of <ICustomCommandArgs>(x =>
                                             x.AssemblyPath == new LiteralScalarResolver <string>(".") &&
                                             x.TypeName == new LiteralScalarResolver <string>("Namespace.NotExistingType") &&
                                             x.Parameters == null
                                             )
            );

            Assert.Throws <NBiException>(instantiate);
        }
Exemplo n.º 3
0
        public void Instantiate_ConstructorNotFound_NotInstantiated()
        {
            var factory = new CustomCommandFactoryProxy();

            void instantiate() => factory.Instantiate
            (
                Mock.Of <ICustomCommandArgs>(x =>
                                             x.AssemblyPath == new LiteralScalarResolver <string>(".") &&
                                             x.TypeName == new LiteralScalarResolver <string>(typeof(CustomCommandWithMulipleCtors).Name) &&
                                             x.Parameters == new ReadOnlyDictionary <string, IScalarResolver>(new Dictionary <string, IScalarResolver>()
            {
                { "NotExistingParameter", new LiteralScalarResolver <string>("foo") }
            })
                                             )
            );

            Assert.Throws <NBiException>(instantiate);
        }