Exemplo n.º 1
0
        public static void FluentIncubatorTest()
        {
            Incubator i = Requesting.A <Primate>().Returns <Monkey>();
            Primate   m = i.Get <Primate>();

            Expect.IsTrue(m.GetType() == typeof(Monkey));
        }
Exemplo n.º 2
0
        public static void IncubatorShouldTakeAFuncAndReturnResult2()
        {
            Incubator i = new Incubator();

            i.Set <Primate>(() => { return(new Monkey()); });
            Primate m = i.Get <Primate>();

            Expect.IsTrue(m.GetType() == typeof(Monkey));
        }
Exemplo n.º 3
0
        public static void IncubatorShouldTakeAFuncAndReturnByClassName()
        {
            Incubator i = new Incubator();

            i.Set <Primate>(() => { return(new Monkey()); });
            object m = i.Get("Primate");

            Expect.IsTrue(m.GetType() == typeof(Monkey));
        }
Exemplo n.º 4
0
        public static void IncubatorShouldTakeAFuncAndPopOutSpecifiedType()
        {
            Incubator i = new Incubator();

            i.Set <Primate>(() => new Monkey());
            object m = i.Get("Primate", out Type type);

            (type == typeof(Primate)).IsTrue();
        }
Exemplo n.º 5
0
        public static void IncubatorShouldGiveMeWhatISet2()
        {
            Incubator i = new Incubator();

            i.Set <Primate>(new Monkey());
            Primate m = i.Get <Primate>();

            Expect.IsTrue(m.GetType() == typeof(Monkey));
        }
Exemplo n.º 6
0
        public void CoreServiceRegistryCopyTest()
        {
            ServiceRegistry reg  = CoreServiceRegistryContainer.Create();
            Incubator       copy = new Incubator();

            copy.CopyFrom(reg);
            IUserResolver userResolver = copy.Get <IUserResolver>();

            Expect.IsNotNull(userResolver);
        }
Exemplo n.º 7
0
        public static void IncubatorShouldTakeAFuncAndReturnResult()
        {
            Incubator      i = new Incubator();
            Func <Primate> f = () => new Monkey();

            i.Set(typeof(Primate), f);
            Primate m = i.Get <Primate>();

            (m.GetType() == typeof(Monkey)).IsTrue();
        }
Exemplo n.º 8
0
        public void GetShouldReturnSameInstanceThatWasSet()
        {
            Incubator inc  = new Incubator();
            TestBam   test = new TestBam();

            inc.Set(typeof(TestBam), test);
            TestBam check = (TestBam)inc.Get(typeof(TestBam), new object[] { });

            Expect.AreSame(test, check);
            Expect.IsTrue(test == check);
        }
Exemplo n.º 9
0
        public static void FluentConstructorTests3()
        {
            Incubator withApple = Requesting.A <IFruit>().Returns <Apple>();

            withApple.Bind <Monkey>().To <Gorilla>();
            Primate p = withApple.Get <Monkey>();

            Expect.IsTrue(p is Gorilla);
            Gorilla g = (Gorilla)p;

            Expect.IsTrue(g.Fruit.GetType() == typeof(Apple));
        }
Exemplo n.º 10
0
        public static void FluentConstructorTests()
        {
            Incubator withBanana = Requesting.A <IFruit>().Returns <Banana>();

            withBanana.AskingFor <Primate>().Returns <Gorilla>();
            Primate p = withBanana.Get <Primate>();

            Expect.IsTrue(p is Gorilla);
            Gorilla g = (Gorilla)p;

            Expect.IsTrue(g.Fruit.GetType() == typeof(Banana));
        }
Exemplo n.º 11
0
        public override void ExecuteResult(ControllerContext context)
        {
            StringBuilder output = new StringBuilder();

            if (string.IsNullOrEmpty(ClassName))
            {
                Tag message = new Tag("div", new { Class = "error" }).Text("ClassName not specified");
                output = new StringBuilder(message.ToHtmlString());
            }
            else
            {
                Incubator incubator = ServiceProxySystem.Incubator;
                Type      type;
                incubator.Get(ClassName, out type);
                if (type == null)
                {
                    Tag message = new Tag("div", new { Class = "error" }).Text("The specified className ({0}) was not registered in the ServiceProxySystem"._Format(ClassName));
                    output = new StringBuilder(message.ToHtmlString());
                }
                else
                {
                    InputFormBuilder formBuilder = new InputFormBuilder(type);
                    formBuilder.Layout = Layout;
                    Dictionary <string, object> defaults = new Dictionary <string, object>();
                    if (Defaults != null)
                    {
                        defaults = Defaults.PropertiesToDictionary();
                    }

                    TagBuilder tag = formBuilder.MethodForm(MethodName, defaults);
                    output = new StringBuilder(tag.ToMvcHtml().ToString());
                }
            }

            HttpResponseBase response = context.HttpContext.Response;

            response.Write(output.ToString());
        }
Exemplo n.º 12
0
        public void CanCreateCatalog()
        {
            string            catalogName = "Test Catalog Name ".RandomLetters(8);
            CatalogService    svc         = _serviceRegistry.Get <CatalogService>();
            CatalogDefinition catalog     = svc.CreateCatalog(catalogName);

            Expect.IsNotNull(catalog, "catalog was null");
            Expect.AreEqual(catalogName, catalog.Name);
            Expect.IsNotNullOrEmpty(catalog.Cuid, "cuid was not set");
        }