Exemplo n.º 1
0
 private Shell CreateShell(
     ShellResolveFactory shellResolveFactory = null)
 {
     return(new Shell(
                this._uriResolvedObjectHolder,
                shellResolveFactory ?? Substitute.For <ShellResolveFactory>()));
 }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the class <see cref="Shell"/>.
        /// </summary>
        /// <param name="uriResolvedObjectHolder">The holder for objects opened by the shell via a URI.</param>
        /// <param name="shellResolveFactory">The factory of an object responsible for URI's resolution beginning.</param>
        public Shell(
            IUriResolvedObjectHolder uriResolvedObjectHolder,
            ShellResolveFactory shellResolveFactory)
        {
            Contract.Requires <ArgumentNullException>(shellResolveFactory != null);
            Contract.Requires <ArgumentNullException>(uriResolvedObjectHolder != null);

            // If user hasn't specified settings, initialize with defaults.
            if (Settings.Instance == null)
            {
                Settings.Initialize(b => { });
            }

            this._shellResolveFactory     = shellResolveFactory;
            this._uriResolvedObjectHolder = uriResolvedObjectHolder;
        }
Exemplo n.º 3
0
        public void ResolvesUriUsingShellResolveFactory()
        {
            Uri factoryUri = null;

            object[] factoryAttachments = null;

            var factory = new ShellResolveFactory(
                (uri, attachments) =>
            {
                factoryUri         = uri;
                factoryAttachments = attachments;

                return(Substitute.For <IShellResolve>());
            });

            var shell = this.CreateShell(shellResolveFactory: factory);

            shell.Resolve(new Uri("tst://tab/module/item"), 1, "2");

            Assert.AreEqual("tst://tab/module/item", factoryUri.OriginalString);
            CollectionAssert.AreEquivalent(new object[] { 1, "2", }, factoryAttachments);
        }