Example #1
0
        public void Changed(string file)
        {
            try
            {
                _lock.Read(() =>
                {
                    var fixture = FixtureReader.ReadFromFile(file);

                    ConsoleWriter.Write($"{file} changed");

                    _fixtures.Models[fixture.key] = fixture;

                    // send to client

                    return(true);
                });
            }
            catch (IOException)
            {
                ConsoleWriter.Write(ConsoleColor.Yellow, $"Unable to reload {file}, file may be locked by your editor");
            }
            catch (Exception e)
            {
                Logger.Error("Failed to handle a changed file: " + file, e);
            }
        }
Example #2
0
        public void can_create_a_new_fixture_file_if_it_does_not_exist()
        {
            theController.CreateFixture("One");

            var file = theFixtureDirectory.AppendPath("One.md");

            File.Exists(file).ShouldBeTrue();

            var fixture = FixtureReader.ReadFromFile(file);

            fixture.key.ShouldBe("One");
            fixture.title.ShouldBe("One");

            theClient.ReceivedWithAnyArgs().SendMessageToClient(new FixturesReloaded());
        }
Example #3
0
        public void does_not_overwrite_an_existing_fixture()
        {
            var file     = theFixtureDirectory.AppendPath("One.md");
            var original = new FixtureModel("One")
            {
                title = "a fancier title"
            };

            FixtureWriter.Write(original, file);

            theController.CreateFixture("One");

            FixtureReader.ReadFromFile(file)
            .title.ShouldBe(original.title);

            theClient.ReceivedCalls().Any().ShouldBeFalse();
        }