public void CreateFromVirtualPathReturnsIHttpHandlerIfItCannotCreateAWebPageType() { // Arrange var pageVirtualPath = "~/hello/test.cshtml"; var handlerVirtualPath = "~/handler.asmx"; var page = new DummyPage(); var handler = new Mock <IHttpHandler>().Object; var mockFactory = new Mock <IVirtualPathFactory>(); mockFactory.Setup(c => c.Exists(It.IsAny <string>())).Returns(true); mockFactory.Setup(c => c.CreateInstance(pageVirtualPath)).Returns(page); mockFactory.Setup(c => c.CreateInstance(handlerVirtualPath)).Returns(handler); // Act var handlerResult = WebPageHttpHandler.CreateFromVirtualPath( handlerVirtualPath, mockFactory.Object ); var pageResult = WebPageHttpHandler.CreateFromVirtualPath( pageVirtualPath, mockFactory.Object ); // Assert Assert.Equal(handler, handlerResult); Assert.NotNull(pageResult as WebPageHttpHandler); }
public void GetLastElement_OneElement() { IVwLayoutStream stream = VwLayoutStreamClass.Create(); using (DummyDivisionMgr division = new DummyDivisionMgr(stream, false)) { using (DummyPublication dummyPub = new DummyPublication(null, division, DateTime.Now)) { using (DummyPage page = new DummyPage(dummyPub)) { PageElement element = new PageElement(division, stream, false, new Rectangle(720, 1440, (int)(6.5 * 720), (int)(9 * 1440)), 0, true, 1, 1, 0, 9 * 1440, 0, false); page.PageElements.Add(element); int xd; PageElement lastElement = page.CallGetLastElement(division, out xd); Assert.AreEqual(element.LocationOnPage.Right, xd); Debug.WriteLine("GetLastElement_OneElement xd: " + xd); Assert.AreEqual(element, lastElement); } } } }
public void GetLastElement_TwoElementsRtoLStandard() { IVwLayoutStream stream = VwLayoutStreamClass.Create(); using (DummyDivisionMgr division = new DummyDivisionMgr(stream, true)) using (DummyPublication dummyPub = new DummyPublication(null, division, DateTime.Now)) using (DummyPage page = new DummyPage(dummyPub)) { PageElement leftColumnElement = new PageElement(division, stream, false, new Rectangle(0, 1440, (int)(3 * 720), (int)(5 * 1440)), 0, true, 1, 2, 0, 5 * 1440, 0, true); PageElement rightColumnElement = new PageElement(division, stream, false, new Rectangle(3 * 720 + 360, 1440, (int)(3 * 720), (int)(9 * 1440)), 0, true, 2, 2, 0, 9 * 1440, 0, true); page.PageElements.Add(leftColumnElement); page.PageElements.Add(rightColumnElement); int xd; PageElement lastElement = page.CallGetLastElement(division, out xd); Debug.WriteLine("GetLastElement_TwoElementsRtoLStandard xd: " + xd); Assert.AreEqual(leftColumnElement, lastElement, "The left-most column should be the last element in a right-to-left writing system"); Assert.AreEqual(0, xd); } }
public void buttonCancel_Click_ShouldCallCloseOnActiveForm() { MockRepository mock = new MockRepository(); Wizard wizard = new Wizard(); IWizardFormFactory formFactory = mock.StrictMock <IWizardFormFactory>(); WizardForm mockForm = mock.DynamicMock <WizardForm>(); DummyPage page = new DummyPage(); wizard.Pages.AddFirst(page); wizard.WizardFormFactory = formFactory; SetUpCommonExpectationsOnFormFactory(formFactory, mockForm); SetUpCommonExpectationsOnForm(mockForm); Expect.Call(mockForm.Close); mock.ReplayAll(); wizard.StartWizard(null); Button button = new Button(); EventArgs e = new EventArgs(); wizard.buttonCancel_Click(button, e); mock.VerifyAll(); }
public void buttonCancel_Click_ShouldCallCloseOnActiveForm() { MockRepository mock = new MockRepository(); Wizard wizard = new Wizard(); IWizardFormFactory formFactory = mock.StrictMock<IWizardFormFactory>(); WizardForm mockForm = mock.DynamicMock<WizardForm>(); DummyPage page = new DummyPage(); wizard.Pages.AddFirst(page); wizard.WizardFormFactory = formFactory; SetUpCommonExpectationsOnFormFactory(formFactory, mockForm); SetUpCommonExpectationsOnForm(mockForm); Expect.Call(mockForm.Close); mock.ReplayAll(); wizard.StartWizard(null); Button button = new Button(); EventArgs e = new EventArgs(); wizard.buttonCancel_Click(button, e); mock.VerifyAll(); }
public void GetPage_ShouldResolveAndReturnPageSpecifiedPageType(string name) { // Arrange var container = Substitute.For <IObjectContainer>(); var expectedPage = new DummyPage(); container.Resolve <DummyPage>(name).Returns(expectedPage); PageProvider.SetContainer(container); // Act var result = PageProvider.GetPage <DummyPage>(name); // Assert result.Should().BeSameAs(expectedPage); }
public void IsReusableTest() { WebPage dummyPage = new DummyPage(); Assert.False(new WebPageHttpHandler(dummyPage).IsReusable); }
public void CreateFromVirtualPathReturnsIHttpHandlerIfItCannotCreateAWebPageType() { // Arrange var pageVirtualPath = "~/hello/test.cshtml"; var handlerVirtualPath = "~/handler.asmx"; var page = new DummyPage(); var handler = new Mock<IHttpHandler>().Object; var mockFactory = new Mock<IVirtualPathFactory>(); mockFactory.Setup(c => c.Exists(It.IsAny<string>())).Returns(true); mockFactory.Setup(c => c.CreateInstance(pageVirtualPath)).Returns(page); mockFactory.Setup(c => c.CreateInstance(handlerVirtualPath)).Returns(handler); // Act var handlerResult = WebPageHttpHandler.CreateFromVirtualPath(handlerVirtualPath, mockFactory.Object); var pageResult = WebPageHttpHandler.CreateFromVirtualPath(pageVirtualPath, mockFactory.Object); // Assert Assert.Equal(handler, handlerResult); Assert.NotNull(pageResult as WebPageHttpHandler); }