Beispiel #1
0
 public GlassUserControlTestHarness()
 {
     SitecoreContext  = Substitute.For <ISitecoreContext>();
     GlassHtml        = Substitute.For <IGlassHtml>();
     RenderingContext = Substitute.For <IRenderingContext>();
     GlassUserControl = new GlassUserControl <StubClass>(SitecoreContext, GlassHtml, RenderingContext);
 }
Beispiel #2
0
        public void Not_setting_glass_html_results_in_original_behaviour()
        {
            // Arrange
            var glassUserControl = new GlassUserControl <StubClass>();

            // Act
            var result = glassUserControl.GlassHtml;

            // Assert - expected NotSupportedException from SitecoreContext cache
        }
Beispiel #3
0
        public void Not_setting_rendering_context_results_in_original_behaviour()
        {
            // Arrange
            var glassUserControl = new GlassUserControl <StubClass>();

            // Act
            IRenderingContext result = glassUserControl.RenderingContext;

            // Assert
            result.Should().NotBeNull();
            result.GetType().Should().Be(typeof(RenderingContextUserControlWrapper));
        }
        public void Not_setting_rendering_context_results_in_original_behaviour()
        {
            // Arrange
            var glassUserControl = new GlassUserControl <StubClass>();

            // Act
            IRenderingContext result = glassUserControl.RenderingContext;

            // Assert
            Assert.NotNull(result);
            Assert.AreEqual(typeof(RenderingContextUserControlWrapper), result.GetType());
        }
        public void Not_setting_sitecore_context_results_in_original_behaviour()
        {
            Assert.Throws <NotSupportedException>(() =>
            {
                // Arrange
                var glassUserControl = new GlassUserControl <StubClass>();

                // Act
                var result = glassUserControl.SitecoreContext;

                // Assert - expected NotSupportedException from SitecoreContext cache
            });
        }
Beispiel #6
0
        [Test] // Most DI frameworks use property injection since the construction is done via the webforms framework
        public void Can_set_values_using_property_injection_successfully()
        {
            // Arrange
            ISitecoreContext  sitecoreContext  = Substitute.For <ISitecoreContext>();
            IRenderingContext renderingContext = Substitute.For <IRenderingContext>();
            IGlassHtml        glassHtml        = Substitute.For <IGlassHtml>();
            var glassUserControl = new GlassUserControl <StubClass>();

            glassUserControl.SitecoreContext  = sitecoreContext;
            glassUserControl.RenderingContext = renderingContext;
            glassUserControl.GlassHtml        = glassHtml;

            // Act - no actions to perform

            // Assert
            glassUserControl.SitecoreContext.Should().Be(sitecoreContext);
            glassUserControl.RenderingContext.Should().Be(renderingContext);
            glassUserControl.GlassHtml.Should().Be(glassHtml);
        }
 public GlassUserControlTestHarness()
 {
     SitecoreContext = Substitute.For<ISitecoreContext>();
     GlassHtml = Substitute.For<IGlassHtml>();
     RenderingContext = Substitute.For<IRenderingContext>();
     GlassUserControl = new GlassUserControl<StubClass>(SitecoreContext, GlassHtml, RenderingContext);
 }
        public void Not_setting_rendering_context_results_in_original_behaviour()
        {
            // Arrange
            var glassUserControl = new GlassUserControl<StubClass>();

            // Act
            IRenderingContext result = glassUserControl.RenderingContext;

            // Assert
            result.Should().NotBeNull();
            result.GetType().Should().Be(typeof (RenderingContextUserControlWrapper));
        }
        public void Not_setting_glass_html_results_in_original_behaviour()
        {
            // Arrange
            var glassUserControl = new GlassUserControl<StubClass>();

            // Act
            var result = glassUserControl.GlassHtml;

            // Assert - expected NotSupportedException from SitecoreContext cache
        }
        [Test] // Most DI frameworks use property injection since the construction is done via the webforms framework
        public void Can_set_values_using_property_injection_successfully()
        {
            // Arrange
            ISitecoreContext sitecoreContext = Substitute.For<ISitecoreContext>();
            IRenderingContext renderingContext = Substitute.For<IRenderingContext>();
            IGlassHtml glassHtml = Substitute.For<IGlassHtml>();
            var glassUserControl = new GlassUserControl<StubClass>();
            glassUserControl.SitecoreContext = sitecoreContext;
            glassUserControl.RenderingContext = renderingContext;
            glassUserControl.GlassHtml = glassHtml;

            // Act - no actions to perform

            // Assert
            glassUserControl.SitecoreContext.Should().Be(sitecoreContext);
            glassUserControl.RenderingContext.Should().Be(renderingContext);
            glassUserControl.GlassHtml.Should().Be(glassHtml);
        }
        public void Not_setting_rendering_context_results_in_original_behaviour()
        {
            // Arrange
            var glassUserControl = new GlassUserControl<StubClass>();

            // Act
            IRenderingContext result = glassUserControl.RenderingContext;

            // Assert
            Assert.NotNull(result);
            Assert.AreEqual(typeof(RenderingContextUserControlWrapper), result.GetType());
        }
        public void Not_setting_sitecore_context_results_in_original_behaviour()
        {
            Assert.Throws<NotSupportedException>(() =>
            {
                // Arrange
                var glassUserControl = new GlassUserControl<StubClass>();

                // Act
                var result = glassUserControl.SitecoreContext;

                // Assert - expected NotSupportedException from SitecoreContext cache
            });

        }