public void TestAtQueryKasterQueryBusExceptionHvisQueryHandlerIkkeErRegistreret()
        {
            var queryBus = new QueryBus(CreateContainer());
            var query    = new TestQueryWithoutQueryHandler();

            Assert.Throws <QueryBusException>(() => queryBus.Query <TestQueryWithoutQueryHandler, Guid>(query));
        }
        public void TestAtQueryKalderQueryHandler()
        {
            var queryBus = new QueryBus(CreateContainer());
            var query    = new TestQuery();
            var id       = queryBus.Query <TestQuery, Guid>(query);

            Assert.That(id, Is.Not.Null);
            Assert.That(id.GetType(), Is.EqualTo(typeof(Guid)));
            Assert.That(id, Is.Not.EqualTo(Guid.Empty));
        }
Пример #3
0
        public void Should_handle_query_with_correct_query_handler()
        {
            var container = new Container();

            container.Register <IQueryHandler <TestQuery, TestQueryResult>, TestQueryHandler>();

            var queryBus = new QueryBus(container);
            var result   = queryBus.Query <TestQuery, TestQueryResult>(new TestQuery());

            Assert.IsTrue(result.QueryHandled);
        }
Пример #4
0
        static void Main()
        {
            var queryHandlerRegistrar = new HandlerRegistrar <IQueryHandler>();

            queryHandlerRegistrar.Register <GetPersonList>(new PersonHandler());
            queryHandlerRegistrar.Register <GetPersonDetails>(new PersonHandler());
            var queryBus = new QueryBus(queryHandlerRegistrar);

            var people = queryBus.Query <GetPersonList, IEnumerable <PersonListItemRecord> >(new GetPersonList());

            Console.WriteLine("People");

            foreach (var person in people.Result)
            {
                Console.WriteLine($"{person.Id} {person.LastName} {person.AddressesCount}");
            }

            Console.WriteLine("Person with id = 1");

            var personDetails = queryBus.Query <GetPersonDetails, PersonDetailsRecord>(new GetPersonDetails(1));

            Console.WriteLine($"{personDetails.Result.FirstName} {personDetails.Result.LastName}");
        }
        public void TestAtQueryKasterArgumentNullExceptionHvisQueryErNull()
        {
            var queryBus = new QueryBus(CreateContainer());

            Assert.Throws <ArgumentNullException>(() => queryBus.Query <TestQuery, Guid>(null));
        }