public void FluentMockServer_ReadStaticMappings()
        {
            _server = FluentMockServer.Start();

            string folder = Path.Combine(GetCurrentFolder(), "__admin", "mappings");

            _server.ReadStaticMappings(folder);

            var mappings = _server.Mappings.ToArray();

            Check.That(mappings).HasSize(3);
        }
        public void FluentMockServer_ReadStaticMappings_FolderExistsIsTrue()
        {
            // Assign
            var _staticMappingHandlerMock = new Mock <IFileSystemHandler>();

            _staticMappingHandlerMock.Setup(m => m.GetMappingFolder()).Returns("folder");
            _staticMappingHandlerMock.Setup(m => m.FolderExists(It.IsAny <string>())).Returns(true);
            _staticMappingHandlerMock.Setup(m => m.EnumerateFiles(It.IsAny <string>())).Returns(new string[0]);

            _server = FluentMockServer.Start(new FluentMockServerSettings
            {
                FileSystemHandler = _staticMappingHandlerMock.Object
            });

            // Act
            _server.ReadStaticMappings();

            // Assert and Verify
            _staticMappingHandlerMock.Verify(m => m.GetMappingFolder(), Times.Once);
            _staticMappingHandlerMock.Verify(m => m.FolderExists("folder"), Times.Once);
            _staticMappingHandlerMock.Verify(m => m.EnumerateFiles("folder"), Times.Once);
        }
Esempio n. 3
0
        private static void Start()
        {
            if (IsRecordMode)
            {
                Server = FluentMockServer.Start(new FluentMockServerSettings
                {
                    StartAdminInterface    = true,
                    ProxyAndRecordSettings = new ProxyAndRecordSettings
                    {
                        Url                = "http://localhost:5001/",
                        SaveMapping        = true,
                        BlackListedHeaders = new[] { "X-ClientId", "Request-Id", "Authorization", "Host" },
                    },
                    Port = 8080
                });
            }
            else
            {
                Server = FluentMockServer.Start(new FluentMockServerSettings
                {
                    Urls = new[] { "http://localhost:8080/" }
                });

                var path = AppDomain.CurrentDomain.BaseDirectory;
                path = path.Remove(path.IndexOf("bin", StringComparison.Ordinal));

                Server.ReadStaticMappings(path + "SavedResponses");
                Server.ReadStaticMappings(path + "SavedResponses/Articles");
                Server.ReadStaticMappings(path + "SavedResponses/Atoz");
                Server.ReadStaticMappings(path + "SavedResponses/Events");
                Server.ReadStaticMappings(path + "SavedResponses/Footer");
                Server.ReadStaticMappings(path + "SavedResponses/Groups");
                Server.ReadStaticMappings(path + "SavedResponses/Homepage");
                Server.ReadStaticMappings(path + "SavedResponses/News");
                Server.ReadStaticMappings(path + "SavedResponses/Showcase");
                Server.ReadStaticMappings(path + "SavedResponses/Topics");
                Server.ReadStaticMappings(path + "SavedResponses/ContactUsArea");
            }
        }