public static void FluentIncubatorTest() { Incubator i = Requesting.A <Primate>().Returns <Monkey>(); Primate m = i.Get <Primate>(); Expect.IsTrue(m.GetType() == typeof(Monkey)); }
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)); }
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)); }
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(); }
public static void IncubatorShouldGiveMeWhatISet2() { Incubator i = new Incubator(); i.Set <Primate>(new Monkey()); Primate m = i.Get <Primate>(); Expect.IsTrue(m.GetType() == typeof(Monkey)); }
public void CoreServiceRegistryCopyTest() { ServiceRegistry reg = CoreServiceRegistryContainer.Create(); Incubator copy = new Incubator(); copy.CopyFrom(reg); IUserResolver userResolver = copy.Get <IUserResolver>(); Expect.IsNotNull(userResolver); }
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(); }
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); }
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)); }
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)); }
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()); }
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"); }