public void GlassController_can_set_and_get_datasource() { // Arrange ID expectedId = new ID(Guid.NewGuid()); DataSourceStubClass classToReturn = new DataSourceStubClass(); var testHarness = new DifferentTypedGlassControllerTestHarness(); testHarness.RenderingContextWrapper.HasDataSource.Returns(true); testHarness.RenderingContextWrapper.GetDataSource().Returns(expectedId.ToString()); testHarness.SitecoreContext.GetItem<DataSourceStubClass>(expectedId.ToString()).Returns(classToReturn); // Act var result1 = testHarness.GlassController.DataSource; var result2 = testHarness.GlassController.DataSource; // Assert result1.Should().Be(classToReturn); result2.Should().BeSameAs(result1); testHarness.SitecoreContext.Received(1).GetItem<DataSourceStubClass>(expectedId.ToString()); }
public void GlassController_can_set_and_get_datasource() { // Arrange ID expectedId = new ID(Guid.NewGuid()); DataSourceStubClass classToReturn = new DataSourceStubClass(); var testHarness = new DifferentTypedGlassControllerTestHarness(); testHarness.RenderingContextWrapper.HasDataSource.Returns(true); testHarness.RenderingContextWrapper.GetDataSource().Returns(expectedId.ToString()); testHarness.SitecoreContext.GetItem <DataSourceStubClass>(expectedId.ToString()).Returns(classToReturn); // Act var result1 = testHarness.GlassController.DataSource; var result2 = testHarness.GlassController.DataSource; // Assert result1.Should().Be(classToReturn); result2.Should().BeSameAs(result1); testHarness.SitecoreContext.Received(1).GetItem <DataSourceStubClass>(expectedId.ToString()); }