/// <summary>
        /// Alle Controller ermitteln die für das Projekt befunden werden können.
        /// </summary>
        public List<Type> GetAllProjectProxyController(ProxySettings proxySettings)
        {
            List<Type> allController = new List<Type>();

            //Alle Assemblies im aktuellen Projekt laden.
            var assemblies = Factory.CreateAssemblyManager().LoadAssemblies(proxySettings.WebProjectName, proxySettings.FullPathToTheWebProject);

            foreach (Assembly assembly in assemblies)
            {
                try
                {
                    //Nur die Assemblies heraussuchen in denen unser BasisAttribut für die Proxy Erstellung gesetzt wurde.
                    var types = assembly.GetTypes().Where(type  => type.GetMethods().Any(p => p.GetCustomAttributes(typeof (CreateProxyBaseAttribute), true).Any())).ToList();

                    foreach (Type type in types)
                    {
                        //Prüfen das jede Klasse (Controller) nur einmal unserer Liste hinzugefügt wird.
                        if (allController.All(p => p.AssemblyQualifiedName != type.AssemblyQualifiedName))
                        {
                            allController.Add(type);
                        }
                    }
                }
                catch(Exception exception)
                {
                    Trace.WriteLine("Fehler beim Auslesen der Assemblies: " + exception.Message);
                }
            }

            return allController;
        }
        public Generator(ProxySettings proxySettings)
        {
            //Wenn man das T4 Template per NuGet akualisiert, werden immer die Einstellungen
            //die man im T4 Template vorgenommen hat überschrieben. Um dies zu verhindern,
            //kann man seine Einstellungen ebenfalls in der Web.Config ablegen und dann wird versucht
            //vorher das Property aus der Web.config auszulesen und mit dem in den ProxySettings ersetzt.
            ISettingsManager settingsManager = new SettingsManager(proxySettings);
            settingsManager.LoadSettingsFromWebConfig();

            Factory = new ProxyGeneratorFactoryManager(proxySettings);
            ControllerManager = Factory.CreateControllerManager();
            GeneratedProxyEntries = new List<GeneratedProxyEntry>();
        }
        public void GetProxyFileOutputPath_Success()
        {
            //Arrange
            var proxySettings = new ProxySettings()
            {
                FullPathToTheWebProject = @"C:\Temp\Files\MyProjectDirectory\OtherDirectory\Bin\Debug\Test",
                WebProjectName = "MyProjectDirectory",
                ProxyFileOutputPath = @"ScriptsApp\services"
            };

            var fileHelper = new FileHelper(new ProxyGeneratorFactoryManager(proxySettings));

            //Act
            var path = fileHelper.GetProxyFileOutputPath("homePSrv.js", null);

            //Assert
            Assert.AreEqual(path, @"C:\Temp\Files\MyProjectDirectory\ScriptsApp\services\homePSrv.js");
        }
        public void GetProxyFileOutputPath_AlternateOutputPath()
        {
            //Arrange
            var proxySettings = new ProxySettings()
            {
                FullPathToTheWebProject = @"C:\Temp\Files\MyProjectDirectory\OtherDirectory\Bin\Debug\Test",
                WebProjectName = "MyProjectDirectory",
                ProxyFileOutputPath = string.Empty
            };

            var fileHelper = new FileHelper(new ProxyGeneratorFactoryManager(proxySettings));

            //Act
            var path = fileHelper.GetProxyFileOutputPath("homePSrv.js", "alternatePath");

            //Assert
            Assert.AreEqual(path, @"C:\Temp\Files\MyProjectDirectory\alternatePath\homePSrv.js");
        }
 public SettingsManager(ProxySettings settings)
 {
     ProxySettings = settings;
 }
        public void Setup()
        {
            //Init
            MockFactory = new Mock<IProxyGeneratorFactoryManager>();
            MockBuildHelper = new Mock<IProxyBuilderHelper>();
            MockBuildHelperHttpCall = new Mock<IProxyBuilderHttpCall>();
            MockSettingsManager = new Mock<ISettingsManager>();

            //Arrange ProxySettings
            var proxySettings = new ProxySettings();
            proxySettings.Templates.Add(new TemplateEntry() { TemplateType = TemplateTypes.AngularJsModule, Template = AngularJsModuleTemplate, TemplateSuffix = "PSrv" });
            proxySettings.Templates.Add(new TemplateEntry() { TemplateType = TemplateTypes.AngularJsPrototype, Template = AngularJsPrototype });
            proxySettings.Templates.Add(new TemplateEntry() { TemplateType = TemplateTypes.AngularJsWindowLocationHref, Template = AngularJsWindowLocationHref });
            MockFactory.Setup(p => p.GetProxySettings()).Returns(proxySettings);

            //Unsere Mockobjekte zuweisen
            AngularJsProxyBuilder = new AngularJsProxyBuilder(MockFactory.Object);
            AngularJsProxyBuilder.ProxyBuilderHelper = MockBuildHelper.Object;
            AngularJsProxyBuilder.ProxyBuilderHttpCall = MockBuildHelperHttpCall.Object;
            AngularJsProxyBuilder.SettingsManager = MockSettingsManager.Object;
        }
        public void TemplateType_AngularJsPrototype_Not_Found()
        {
            //Arrange
            AutoMocker mocker = new AutoMocker();
            var proxySettings = new ProxySettings();
            proxySettings.Templates.Add(new TemplateEntry() { TemplateType = TemplateTypes.AngularJsModule });

            mocker.Use<IProxyGeneratorFactoryManager>(new ProxyGeneratorFactoryManager(proxySettings));
            var myMock = mocker.CreateInstance<AngularJsProxyBuilder>();

            //Act
            var generatedProxyEntries = myMock.BuildProxy(new List<ProxyControllerInfo>());
        }
 public ProxyBuilderHelper(ProxySettings proxySettings)
 {
     ProxySettings = proxySettings;
 }
 public ProxyGeneratorFactoryManager(ProxySettings proxySettings)
 {
     ProxySettings = proxySettings;
 }