public void CreateInstance_ThrowsPageTypeBuilderExceptionForTypeWithNoPublicCtor() { StructureMapTypedPageActivator activator = new StructureMapTypedPageActivator(null); Exception thrownException = Record.Exception(() => activator.CreateInstance(typeof(PageTypeWithNoPublicConstructor))); Assert.NotNull(thrownException); Assert.IsType <PageTypeBuilderException>(thrownException); }
public void CreateInstance_UsesInjectedContainerToCreateInstanceOfRequestedType() { string expectedCtorParam = Guid.NewGuid().ToString(); Mock <IContainer> fakeContainer = new Mock <IContainer>(); fakeContainer.Setup(container => container.GetInstance(typeof(string))).Returns(expectedCtorParam); StructureMapTypedPageActivator activator = new StructureMapTypedPageActivator(fakeContainer.Object); PageTypeWithStringCtorParam pageData = (PageTypeWithStringCtorParam)activator.CreateInstance(typeof(PageTypeWithStringCtorParam)); Assert.Equal <string>(expectedCtorParam, pageData.Injected); }