public void GetVirtualPath_TestAssembly_ReturnsAssemblyNameWithPrefix()
        {
            var controllerAssembly = Assembly.GetExecutingAssembly();
            var result = new VirtualPathBuilder().GetVirtualPath(controllerAssembly);

            Assert.AreEqual("Frontend-Assembly/Telerik.Sitefinity.Frontend.Test/", result);
        }
        public void GetVirtualPath_TestAssembly_ReturnsAssemblyNameWithPrefix()
        {
            //Arrange
            var controllerAssembly = Assembly.GetExecutingAssembly();

            //Act
            var result = new VirtualPathBuilder().GetVirtualPath(controllerAssembly);

            //Assert
            Assert.AreEqual("Frontend-Assembly/Telerik.Sitefinity.Frontend.Test/", result, "The virtual path is not resolved correctly.");
        }
        public void AddParams_WithoutParams_PreservesUrl()
        {
            // Arrange
            var virtualPathBuilder = new VirtualPathBuilder();
            string urlWithoutParams = "/sfLayouts/test.master";

            // Act
            string resultUrl = virtualPathBuilder.AddParams(urlWithoutParams, string.Empty);

            // Assert
            Assert.AreEqual(urlWithoutParams, resultUrl, "The URL has been changed.");
        }
        public void AddParams_WithParams_AddsParams()
        {
            // Arrange
            var virtualPathBuilder = new VirtualPathBuilder();
            string urlWithParams = "/sfLayouts/test.master#someParam.master";
            string url = "/sfLayouts/test.master";

            // Act
            string resultUrl = virtualPathBuilder.AddParams(url, "someParam");

            // Assert
            Assert.AreEqual(urlWithParams, resultUrl, "The parameters are not added correctly from the URL.");
        }
        public void GetVirtualPath_RegisteredWidget_ReturnsVirtualPathForItsAssembly()
        {
            var controllerAssembly = typeof(DummyController).Assembly;
            var vpBuilder = new VirtualPathBuilder();
            var expected = vpBuilder.GetVirtualPath(controllerAssembly);

            using (var factoryReg = new ControllerFactoryRegion<DummyControllerFactory>())
            {
                factoryReg.Factory.ControllerRegistry["Dummy"] = typeof(DummyController);

                var result = vpBuilder.GetVirtualPath(typeof(DummyController));
                Assert.AreEqual(expected, result);
            }
        }
        public void GetVirtualPath_RegisteredWidget_ReturnsVirtualPathForItsAssembly()
        {
            // Arrange
            Assembly controllerAssembly = typeof(DummyController).Assembly;
            var virtualPathBuilder = new VirtualPathBuilder();
            string expected = virtualPathBuilder.GetVirtualPath(controllerAssembly);

            using (var factoryReg = new ControllerFactoryRegion<DummyControllerFactory>())
            {
                factoryReg.Factory.ControllerRegistry["Dummy"] = typeof(DummyController);

                // Act
                string result = virtualPathBuilder.GetVirtualPath(typeof(DummyController));

                // Assert
                Assert.AreEqual(expected, result, "The virtual path is not retrieved properly.");
            }
        }
        public void RemoveParams_UrlWithParams_RemovesParams()
        {
            // Arrange
            var virtualPathBuilder = new VirtualPathBuilder();
            string urlWithParams = "/sfLayouts/test.master#someParam.master";
            string expectedUrl = "/sfLayouts/test.master";

            // Act
            string resultUrl = virtualPathBuilder.RemoveParams(urlWithParams);

            // Assert
            Assert.AreEqual(expectedUrl, resultUrl, "The parameters are not stripped correctly from the URL.");
        }