コード例 #1
0
        public void DeleteAssemblyShouldNotThrowIfAssemblyNotFound() {
            var clock = new StubClock();
            var appDataFolder = new StubAppDataFolder(clock);
            var dependenciesFolder = new DefaultAssemblyProbingFolder(appDataFolder, new DefaultAssemblyLoader(Enumerable.Empty<IAssemblyNameResolver>()));

            Assert.DoesNotThrow(() => dependenciesFolder.DeleteAssembly("foo"));
        }
コード例 #2
0
        public void GetAssemblyDateTimeUtcShouldThrowIfAssemblyNotFound() {
            var clock = new StubClock();
            var appDataFolder = new StubAppDataFolder(clock);
            var dependenciesFolder = new DefaultAssemblyProbingFolder(appDataFolder, new DefaultAssemblyLoader(Enumerable.Empty<IAssemblyNameResolver>()));

            Assert.That(() => dependenciesFolder.GetAssemblyDateTimeUtc("foo"), Throws.Exception);
        }
コード例 #3
0
        public void LoadAssemblyShouldNotThrowIfAssemblyNotFound() {
            var clock = new StubClock();
            var appDataFolder = new StubAppDataFolder(clock);
            var dependenciesFolder = new DefaultAssemblyProbingFolder(appDataFolder, new DefaultAssemblyLoader(Enumerable.Empty<IAssemblyNameResolver>()));

            Assert.That(dependenciesFolder.LoadAssembly("foo"), Is.Null);
        }
コード例 #4
0
        public void FolderShouldBeEmptyByDefault() {
            var clock = new StubClock();
            var appDataFolder = new StubAppDataFolder(clock);
            var dependenciesFolder = new DefaultAssemblyProbingFolder(appDataFolder, new DefaultAssemblyLoader(Enumerable.Empty<IAssemblyNameResolver>()));

            Assert.That(dependenciesFolder.AssemblyExists("foo"), Is.False);
        }
コード例 #5
0
        public void Init() {
            var clock = new StubClock();
            var appDataFolder = new StubAppDataFolder(clock);

            _controllerBuilder = new ControllerBuilder();
            _routeCollection = new RouteCollection();
            _modelBinderDictionary = new ModelBinderDictionary();
            _viewEngineCollection = new ViewEngineCollection { new WebFormViewEngine() };

            _container = OrchardStarter.CreateHostContainer(
                builder => {
                    builder.RegisterInstance(new StubShellSettingsLoader()).As<IShellSettingsManager>();
                    builder.RegisterType<RoutePublisher>().As<IRoutePublisher>();
                    builder.RegisterType<ModelBinderPublisher>().As<IModelBinderPublisher>();
                    builder.RegisterType<ShellContextFactory>().As<IShellContextFactory>();
                    builder.RegisterType<StubExtensionManager>().As<IExtensionManager>();
                    builder.RegisterType<StubVirtualPathMonitor>().As<IVirtualPathMonitor>();
                    builder.RegisterInstance(appDataFolder).As<IAppDataFolder>();
                    builder.RegisterInstance(_controllerBuilder);
                    builder.RegisterInstance(_routeCollection);
                    builder.RegisterInstance(_modelBinderDictionary);
                    builder.RegisterInstance(_viewEngineCollection);
                    builder.RegisterAutoMocking()
                        .Ignore<IExtensionFolders>()
                        .Ignore<IRouteProvider>()
                        .Ignore<IHttpRouteProvider>()
                        .Ignore<IModelBinderProvider>()
                        .Ignore<IWorkContextEvents>()
                        .Ignore<IOwinMiddlewareProvider>();
                });
            _lifetime = _container.BeginLifetimeScope();

            _container.Mock<IContainerProvider>()
                .SetupGet(cp => cp.ApplicationContainer).Returns(_container);
            _container.Mock<IContainerProvider>()
                .SetupGet(cp => cp.RequestLifetime).Returns(_lifetime);
            _container.Mock<IContainerProvider>()
                .Setup(cp => cp.EndRequestLifetime()).Callback(() => _lifetime.Dispose());

            _container.Mock<IShellDescriptorManager>()
                .Setup(cp => cp.GetShellDescriptor()).Returns(default(ShellDescriptor));

            _container.Mock<IOrchardShellEvents>()
                .Setup(e => e.Activated());

            _container.Mock<IOrchardShellEvents>()
                .Setup(e => e.Terminating()).Callback(() => new object());
        }
コード例 #6
0
        public void StoreAssemblyShouldCopyFile() {
            var clock = new StubClock();
            var appDataFolder = new StubAppDataFolder(clock);

            var assembly = GetType().Assembly;
            var name = assembly.GetName().Name;

            {
                var dependenciesFolder = new DefaultAssemblyProbingFolder(appDataFolder, new DefaultAssemblyLoader(Enumerable.Empty<IAssemblyNameResolver>()));
                dependenciesFolder.StoreAssembly(name, assembly.Location);
            }

            {
                var dependenciesFolder = new DefaultAssemblyProbingFolder(appDataFolder, new DefaultAssemblyLoader(Enumerable.Empty<IAssemblyNameResolver>()));
                Assert.That(dependenciesFolder.AssemblyExists(name), Is.True);
                Assert.That(dependenciesFolder.LoadAssembly(name), Is.SameAs(GetType().Assembly));
                Assert.DoesNotThrow(() => dependenciesFolder.DeleteAssembly(name));
                Assert.That(dependenciesFolder.LoadAssembly(name), Is.Null);
            }
        }
コード例 #7
0
 public void Init() {
     var clock = new StubClock();
     _appDataFolder = new StubAppDataFolder(clock);
 }