Exemplo n.º 1
0
        public void SetUp()
        {
            file1 = ParsingScenario.Create(scenario =>
            {
                scenario.WriteLine("MyFirstSettings:");
                scenario.WriteLine("  property1: 'string value'");
                scenario.WriteLine("  property2: 'another string value'");
                scenario.WriteLine("");

                scenario.WriteLine("MySecondSettings:");
                scenario.WriteLine("  anotherProperty1: 'some value'");
                scenario.WriteLine("  anotherProperty2: 'another value of some kind'");
            });

            file2 = ParsingScenario.Create(scenario =>
            {
                scenario.WriteLine("MyThirdSettings:");
                scenario.WriteLine("  someProperty: 'random value'");
            });

            theSettings = new ObjectBlockFileSettings();
            theSettings.AddFile(file1.FileName);
            theSettings.AddFile(file2.FileName);

            theSource = new ObjectBlockFileSource(theSettings, new FileSystem(), ObjectBlockReader.Basic());
        }
Exemplo n.º 2
0
        public ParsingScenario(string fileName)
        {
            _fileName = fileName;
            _files    = new FileSystem();

            _parser = new ObjectBlockParser();

            _blockRegistry = BlockRegistry.Basic();
            _reader        = new ObjectBlockReader(_parser, ObjectResolver.Basic(), new InMemoryServiceLocator(), _blockRegistry);
        }
        // ENDSAMPLE

        // SAMPLE: Deserialize
        public void deserialize()
        {
            var fileSystem = new FileSystem();

            // You can also register IObjectBlockReader/ObjectBlockReader
            // into your container
            var reader = ObjectBlockReader.Basic();

            var contents = fileSystem.ReadStringFromFile("syntax.txt");
            var solution = reader.Read <Solution>(contents);
        }
Exemplo n.º 4
0
        public void SetUp()
        {
            theScenario = ParsingScenario.Create(scenario =>
            {
                scenario.WriteLine("MySettings:");
                scenario.WriteLine("  property1: 'string value'");
                scenario.WriteLine("  property2: 'another string value'");
            });

            theFileSettings = new ObjectBlockFileSettings();
            theFileSettings.AddFile(theScenario.FileName);

            theReader   = ObjectBlockReader.Basic();
            theSource   = new ObjectBlockFileSource(theFileSettings, new FileSystem(), theReader);
            theProvider = new ObjectBlockSettingsProvider(new IObjectBlockSource[] { theSource }, theReader);

            theSettings = theProvider.SettingsFor <MySettings>();
        }
        public void reads_and_writes()
        {
            var solution = new Solution
            {
                Options = new SolutionOptions
                {
                    Name             = new SolutionName("ripple"),
                    Nuspecs          = "packaging/nuget",
                    SrcFolder        = "src",
                    BuildCmd         = "rake",
                    FastBuildCommand = "rake compile",
                    Constraints      = new SolutionConstraints
                    {
                        Float = "current",
                        Fixed = "current,nextMajor"
                    }
                },
                Feeds = new[]
                {
                    new Feed
                    {
                        Url       = "http://build.fubu-project.org/guestAuth/app/nuget/v1/FeedService.svc",
                        Mode      = "float",
                        Stability = "released"
                    },
                    new Feed {
                        Url = "http://nuget.org/api/v2", Mode = "fixed", Stability = "released"
                    }
                }
            };


            var reader = ObjectBlockReader.Basic();
            var writer = ObjectBlockWriter.Basic();

            var output = writer.Write(solution);

            Debug.WriteLine(output);

            var newSolution = reader.Read <Solution>(output);

            newSolution.ShouldEqual(solution);
        }