예제 #1
0
        public void sets_the_properties()
        {
            var target = new SuperComplexTarget
            {
                Name  = "test",
                Feeds = new[]
                {
                    new Feed {
                        Url = "http://localhost:8080", Mode = "fixed"
                    },
                    new Feed {
                        Url = "http://localhost:8181", Mode = "float"
                    }
                }
            };

            var writer = ObjectBlockWriter.Basic();
            var block  = writer.BlockFor(target);

            block.FindBlock <PropertyBlock>("name").Value.ShouldEqual("test");

            var feeds = block.FindBlock <CollectionBlock>("feed").Blocks.ToArray();

            feeds[0].ImplicitValue.ShouldEqual("http://localhost:8080");
            feeds[0].FindBlock <PropertyBlock>("mode").Value.ShouldEqual("fixed");

            feeds[1].ImplicitValue.ShouldEqual("http://localhost:8181");
            feeds[1].FindBlock <PropertyBlock>("mode").Value.ShouldEqual("float");
        }
예제 #2
0
        public void Write(Solution solution)
        {
            var writer  = ObjectBlockWriter.Basic(new RippleBlockRegistry());
            var content = writer.Write(solution);

            _fileSystem.WriteStringToFile(solution.Path, content);
        }
예제 #3
0
        public static PersistenceExpression <Solution> ForSolution(Solution target)
        {
            var file       = "{0}-{1}.config".ToFormat(typeof(Solution).Name, Guid.NewGuid());
            var fileSystem = new FileSystem();

            if (fileSystem.FileExists(file))
            {
                fileSystem.DeleteFile(file);
            }

            var writer   = ObjectBlockWriter.Basic(new RippleBlockRegistry());
            var contents = writer.Write(target);

            Debug.WriteLine(contents);
            fileSystem.WriteStringToFile(file, contents);

            var reader = SolutionLoader.Reader();

            var specification = new PersistenceSpecification <Solution>(x =>
            {
                var fileContents = fileSystem.ReadStringFromFile(file);
                var readValue    = Solution.Empty();
                reader.Read(readValue, fileContents);

                fileSystem.DeleteFile(file);

                return(readValue);
            });

            specification.Original = target;

            return(new PersistenceExpression <Solution>(specification));
        }
        // ENDSAMPLE

        // SAMPLE: Serialize
        public void serialize()
        {
            var solution = new Solution {
                Options = new SolutionOptions {
                    Name = new SolutionName("test")
                }
            };
            var writer = ObjectBlockWriter.Basic();

            var serializedString = writer.Write(solution);
        }
예제 #5
0
        public static BlockWritingContext ContextFor <T>(Expression <Func <T, object> > expression, object subject = null)
        {
            var property = ReflectionHelper.GetProperty(expression);

            var services = new InMemoryServiceLocator();

            services.Add <IDisplayFormatter>(new DisplayFormatter(services, new Stringifier()));

            var context = new BlockWritingContext(services, ObjectBlockWriter.Basic(), BlockRegistry.Basic(), subject);

            context.StartProperty(property);

            return(context);
        }
        public void excludes_the_ignored_properties()
        {
            var target = new ComplexTarget
            {
                Name   = "test",
                Nested = new NestedTarget {
                    Email = "*****@*****.**"
                }
            };

            var writer = ObjectBlockWriter.Basic(x => x.RegisterSettings <ComplexTargetSettings>());

            var block = writer.BlockFor(target);

            block.FindProperty("name").Value.ShouldEqual("test");

            block.FindNested("nested").ShouldBeNull();
        }
예제 #7
0
        public void SingleBlockTest()
        {
            var content = new string('X', 100);

            var blocks = new List<FragmentBlock>();
            var bw = new ObjectBlockWriter(b => blocks.Add(b));

            using (var s = new BizTalkBlockStream(bw))
            using (var sw = new StreamWriter(s))
            {
                sw.Write(content);
            }

            Assert.AreEqual(2, blocks.Count);
            Assert.IsTrue(blocks.Last().IsEmpty);

            Assert.AreEqual(100, blocks[0].UncompressedLength);
        }
예제 #8
0
        public void SingleBlockTest()
        {
            var content = new string('X', 100);

            var blocks = new List <FragmentBlock>();
            var bw     = new ObjectBlockWriter(b => blocks.Add(b));

            using (var s = new BizTalkBlockStream(bw))
                using (var sw = new StreamWriter(s))
                {
                    sw.Write(content);
                }

            Assert.AreEqual(2, blocks.Count);
            Assert.IsTrue(blocks.Last().IsEmpty);

            Assert.AreEqual(100, blocks[0].UncompressedLength);
        }
        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);
        }
        public void sets_the_properties()
        {
            var target = new ComplexTarget
            {
                Name   = "test",
                Nested = new NestedTarget {
                    Email = "*****@*****.**"
                }
            };

            var writer = ObjectBlockWriter.Basic();

            var block = writer.BlockFor(target);

            block.FindProperty("name").Value.ShouldEqual("test");

            var nested = block.FindNested("nested");

            nested.FindProperty("email").Value.ShouldEqual("*****@*****.**");
        }
예제 #11
0
        public void sets_the_properties()
        {
            var target = new SimpleTarget {
                Key = "test", Value = "value"
            };
            var writer = ObjectBlockWriter.Basic();

            var block = writer.BlockFor(target);

            Action <string, string> assert = (name, value) =>
            {
                var result = block.FindProperty(name);
                result.ShouldNotBeNull();
                result.Name.ShouldEqual(name.FirstLetterLowercase());
                result.Value.ShouldEqual(value);
            };

            assert("Key", "test");
            assert("Value", "value");
        }