Ejemplo n.º 1
0
        public void SimpleSchema()
        {
            var language = new LanguageSchemaBuilder().Add <DemoAgg>().Build();

            language.Aggregates.Count.ShouldBe(1);

            Should.NotThrow(() => language.GetAggregate(typeof(DemoAgg)));
            var aggInfo = language.GetAggregate(typeof(DemoAgg));

            language.GetAggregate(typeof(DemoAgg)).ShouldBe(aggInfo);
            aggInfo.Type.ShouldBe(typeof(DemoAgg));
            aggInfo.Name.ShouldBe(nameof(DemoAgg));

            aggInfo.Commands.ShouldNotBeNull();
            aggInfo.Commands.Count.ShouldBe(1);
            var cmdInfo = aggInfo.Commands.Single();

            language.GetCommand(typeof(DemoAgg.Cmd)).ShouldBe(cmdInfo);
            language.FindCommand("DemoAgg", "Cmd").Type.ShouldBe(typeof(DemoAgg.Cmd));
            cmdInfo.Type.ShouldBe(typeof(DemoAgg.Cmd));
            cmdInfo.Name.ShouldBe(nameof(DemoAgg.Cmd));

            aggInfo.Views.ShouldNotBeNull();
            aggInfo.Views.Count.ShouldBe(1);
            var viewInfo = aggInfo.Views.Single();

            language.GetAggregateView(typeof(DemoAgg.View)).ShouldBe(viewInfo);
        }
Ejemplo n.º 2
0
        public void EmptySchema()
        {
            var schema = new LanguageSchemaBuilder().Build();

            schema.Aggregates.ShouldNotBeNull();
            schema.Aggregates.ShouldBeEmpty();

            Should.Throw <ArgumentNullException>(() => schema.GetAggregate(null));
            Should.Throw <ArgumentNullException>(() => schema.GetCommand(null));
            Should.Throw <ArgumentNullException>(() => schema.GetQuery(null));

            var anyTermType = typeof(Object); // no matter what it is because language is empty

            Should.Throw <ArgumentOutOfRangeException>(() => schema.GetAggregate(anyTermType));
            Should.Throw <ArgumentOutOfRangeException>(() => schema.GetCommand(anyTermType));
            Should.Throw <ArgumentOutOfRangeException>(() => schema.GetQuery(anyTermType));

            var anyTermName = "sdfsdf"; // no matter what it is because language is empty

            Should.Throw <LanguageSchemaException>(() => schema.FindCommand(anyTermName, anyTermName));
        }