public void FluentMockServer_ReadStaticMapping_WithResponseBodyFromFile()
        {
            string guid = "00000002-ee28-4f29-ae63-1ac9b0802d87";

            string folder = Path.Combine(GetCurrentFolder(), "__admin", "mappings", guid + ".json");
            string json   = File.ReadAllText(folder);

            string responseBodyFilePath = Path.Combine(GetCurrentFolder(), "responsebody.json");

            dynamic jsonObj = JsonConvert.DeserializeObject(json);

            jsonObj["Response"]["BodyAsFile"] = responseBodyFilePath;

            string output = JsonConvert.SerializeObject(jsonObj, Formatting.Indented);

            File.WriteAllText(folder, output);

            _server = FluentMockServer.Start();
            _server.ReadStaticMappingAndAddOrUpdate(folder);

            var mappings = _server.Mappings.ToArray();

            Check.That(mappings).HasSize(1);

            Check.That(mappings.First().RequestMatcher).IsNotNull();
            Check.That(mappings.First().Provider).IsNotNull();
            Check.That(mappings.First().Guid).Equals(Guid.Parse(guid));
            Check.That(mappings.First().Title).IsNullOrEmpty();
        }
        public void FluentMockServer_ReadStaticMapping_WithGuidFilename()
        {
            string guid = "00000002-ee28-4f29-ae63-1ac9b0802d86";

            _server = FluentMockServer.Start();
            string folder = Path.Combine(GetCurrentFolder(), "__admin", "mappings", guid + ".json");

            _server.ReadStaticMappingAndAddOrUpdate(folder);

            var mappings = _server.Mappings.ToArray();

            Check.That(mappings).HasSize(1);

            Check.That(mappings.First().RequestMatcher).IsNotNull();
            Check.That(mappings.First().Provider).IsNotNull();
            Check.That(mappings.First().Guid).Equals(Guid.Parse(guid));
            Check.That(mappings.First().Title).IsNullOrEmpty();
        }
        public void FluentMockServer_ReadStaticMappingAndAddOrUpdate()
        {
            // Assign
            string mapping = "{\"Request\": {\"Path\": {\"Matchers\": [{\"Name\": \"WildcardMatcher\",\"Pattern\": \"/static/mapping\"}]},\"Methods\": [\"get\"]},\"Response\": {\"BodyAsJson\": { \"body\": \"static mapping\" }}}";
            var    _staticMappingHandlerMock = new Mock <IFileSystemHandler>();

            _staticMappingHandlerMock.Setup(m => m.ReadMappingFile(It.IsAny <string>())).Returns(mapping);

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

            // Act
            _server.ReadStaticMappingAndAddOrUpdate(@"c:\test.json");

            // Assert and Verify
            _staticMappingHandlerMock.Verify(m => m.ReadMappingFile(@"c:\test.json"), Times.Once);
        }
        public void FluentMockServer_ReadStaticMapping_WithNonGuidFilename()
        {
            var    guid  = Guid.Parse("04ee4872-9efd-4770-90d3-88d445265d0d");
            string title = "documentdb_root_title";

            _server = FluentMockServer.Start();

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

            _server.ReadStaticMappingAndAddOrUpdate(folder);

            var mappings = _server.Mappings.ToArray();

            Check.That(mappings).HasSize(1);

            Check.That(mappings.First().RequestMatcher).IsNotNull();
            Check.That(mappings.First().Provider).IsNotNull();
            Check.That(mappings.First().Guid).Equals(guid);
            Check.That(mappings.First().Title).Equals(title);
        }