Пример #1
0
        public Dramaticon Dramaticon_FromNew()
        {
            Dramaticon dramaticon = new Dramaticon();

            dramaticon.HasClearedRot = false;
            return(dramaticon);
        }
Пример #2
0
        public void CanRT_Compendium()
        {
            //var creator = new BeingCreator(__factory);
            var publisher      = new BookPublisher(_creator);
            var tomeOfChaos    = publisher.Tome_FromNew("gloop");
            var herbal         = new Herbal();
            var socialRegister = new SocialRegister(_creator);
            var dramaticon     = new Dramaticon();
            var atlas          = new Atlas();

            var idGen      = new IDGenerator(33);
            var compendium = new Compendium(idGen, _creator, tomeOfChaos, herbal, socialRegister, dramaticon, atlas);

            var yaml = _serializer.Serialize(compendium);

            Assert.That(yaml, Is.Not.Null);

            var newBook = _deserializer.Deserialize <IBook>(yaml);

            Assert.That(newBook, Is.TypeOf <Compendium>());
            var newCompendium = (Compendium)newBook;

            Assert.That(newCompendium.IDGenerator.UseID(), Is.EqualTo(33));
            Assert.That(newCompendium.TomeOfChaos.TopSeed, Is.EqualTo("gloop"));

            //TODO: slightly more muscular checks once these books go beyond placeholders
            Assert.That(newCompendium.Herbal, Is.Not.Null);
            Assert.That(newCompendium.SocialRegister, Is.Not.Null);
            Assert.That(newCompendium.Dramaticon, Is.Not.Null);
            Assert.That(newCompendium.Atlas, Is.Not.Null);
        }
Пример #3
0
        public Dramaticon Dramaticon_FromYaml(IParser parser)
        {
            parser.Consume <MappingStart>();

            Dramaticon dramaticon = new Dramaticon();

            dramaticon.HasClearedRot = parser.GetKVP_bool("HasClearedRot");

            parser.Consume <MappingEnd>();
            return(dramaticon);
        }
Пример #4
0
        public void CanRT_Dramaticon()
        {
            //if (!Debugger.IsAttached) Debugger.Launch();
            var drama = new Dramaticon
            {
                HasClearedRot = true
            };

            var yaml = _serializer.Serialize(drama);

            Assert.That(yaml, Is.Not.Null);

            var newBook = _deserializer.Deserialize <IBook>(yaml);

            Assert.That(newBook, Is.TypeOf <Dramaticon>());
            var newDramaticon = (Dramaticon)newBook;

            Assert.That(newDramaticon.HasClearedRot);
        }
Пример #5
0
        public IBook Compendium_FromYaml(IParser parser)
        {
            parser.Consume <MappingStart>();

            uint        nextID = uint.Parse(parser.GetKVP_string("NextID"));
            IDGenerator idGen  = new IDGenerator(nextID);

            TomeOfChaos    tome     = null;
            Herbal         herbal   = null;
            SocialRegister register = null;
            Dramaticon     drama    = null;
            Atlas          atlas    = null;

            while (parser.TryConsume <Scalar>(out var next))
            {
                switch (next.Value)
                {
                case "TomeOfChaos": tome = Tome_FromYaml(parser); break;

                case "Herbal": herbal = Herbal_FromYaml(parser); break;

                case "SocialRegister": register = Register_FromYaml(parser, BeingCreator); break;

                case "Dramaticon": drama = Dramaticon_FromYaml(parser); break;

                case "Atlas": atlas = Atlas_FromYaml(parser); break;

                default:
                    throw new NotImplementedException($"Cannot yet parse a [{next.Value}] for Compendium.");
                }
            }

            var compendium = new Compendium(idGen, BeingCreator, tome, herbal, register, drama, atlas);

            parser.Consume <MappingEnd>();
            return(compendium);
        }