Inheritance: IQueryHandler
Ejemplo n.º 1
0
 public void RegisterHandler(QueryHandler queryHandler)
 {
   foreach(var commandType in queryHandler.GetHandledQueries())
   {
     _handlers.Add(commandType, queryHandler);
   }
 }
Ejemplo n.º 2
0
        public void LingToHibernateTesting()
        {
            CanSaveCompany();

            linqCompany = UnitOfWork.CurrentSession.Linq<Company>();

            //FIRST METHOD
            var q = (from comp in linqCompany
                     where comp.ID == "MSZ"
                     select comp).First();

            //SECOND METHOD
            var queryHandler = new QueryHandler<Company>();
            queryHandler.AddCriteria(comp => comp.ID == "MSZ");
            var p = queryHandler.GetList().First();

            bool t = q == p;
            int totalCount = 1;//q.Count();
            
            //var query = from user in session.Linq<User>()
            //            select new { user.Name, RoleName = user.Role.Name };
            //Assert.AreEqual(3, totalCount);
            
            //var p = (from item in UnitOfWork.CurrentSession.Linq<Product>()
            //         where item.Title == ID
            //         select item).First(); 
        }
Ejemplo n.º 3
0
        public void TestInversionOfControl()
        {
            MockContextFactory.SeedAndTestContextFor("FilterTests_TestInversionOfControl", TestSeeders.SimpleSeedScenario, ctx =>
            {
                var resultShouldMatch = ctx.Customers.Where(t => t.FirstName == "Chuck").ToList();

                var criteria = new QueryCriteria()
                {
                    Filters = new List <IFilter> {
                        new MockIsChuckFilter()
                    }
                };

                var queryHandler = new QueryHandler(Enumerable.Empty <IQueryInterceptorProvider>());
                var result       = queryHandler.Execute(ctx.Customers, criteria);
                Assert.Equal(resultShouldMatch, result.Data);
            });
        }
Ejemplo n.º 4
0
        private void SQLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog sd = new SaveFileDialog
            {
                FileName = MyData.Field_entry.ToString() + "_" + MyData.Field_name,
                Filter   = "SQL File | *.sql"
            };

            if (sd.ShowDialog() == DialogResult.OK)
            {
                using (StreamWriter sw = new StreamWriter(sd.FileName))
                {
                    sw.Write(QueryHandler.GetExportQuery());
                    sw.Flush();
                    sw.Close();
                }
            }
        }
        public async Task Should_add_given_participants_to_hearing_and_not_PublishParticipantsAddedEvent_if_no_matching_participant_with_username()
        {
            var hearing      = GetVideoHearing(true);
            var participants = BuildParticipants(3);

            request = new AddParticipantsToHearingRequest {
                Participants = participants
            };
            QueryHandler.Setup(q => q.Handle <GetHearingByIdQuery, VideoHearing>(It.IsAny <GetHearingByIdQuery>())).ReturnsAsync(hearing);

            var response = await Controller.AddParticipantsToHearing(hearingId, request);

            response.Should().NotBeNull();
            QueryHandler.Verify(q => q.Handle <GetHearingByIdQuery, VideoHearing>(It.IsAny <GetHearingByIdQuery>()), Times.Exactly(2));
            QueryHandler.Verify(q => q.Handle <GetCaseTypeQuery, CaseType>(It.IsAny <GetCaseTypeQuery>()), Times.Once);
            CommandHandler.Verify(c => c.Handle(It.IsAny <AddParticipantsToVideoHearingCommand>()), Times.Once);
            EventPublisher.Verify(e => e.PublishAsync(It.IsAny <ParticipantsAddedIntegrationEvent>()), Times.Never);
        }
        public async Task Should_succesfully_return_notfound_without_matching_caserole()
        {
            var caseTypeName = "test";
            var caseRoleName = "TestRole";
            var caseType     = new CaseType(1, "Civil")
            {
                CaseRoles = new List <CaseRole>()
            };

            QueryHandler.Setup(q => q.Handle <GetCaseTypeQuery, CaseType>(It.IsAny <GetCaseTypeQuery>())).ReturnsAsync(caseType);

            var result = await Controller.GetHearingRolesForCaseRole(caseTypeName, caseRoleName);

            result.Should().NotBeNull();
            var objectResult = (NotFoundResult)result;

            objectResult.StatusCode.Should().Be((int)HttpStatusCode.NotFound);
        }
Ejemplo n.º 7
0
        public void TestPaging()
        {
            MockContextFactory.SeedAndTestContextFor("CriteriaTests_TestPagging", TestSeeders.SimpleSeedScenario, ctx =>
            {
                var resultShouldMatch = ctx.OrderItems.OrderBy(t => t.Id).Skip(5).Take(5).ToList();

                // query handler that is empty should be the same as running to list.
                var criteria = new QueryCriteria();
                criteria.Sorts.Add(new Sort("Id"));
                criteria.Page     = 2;
                criteria.PageSize = 5;

                var queryHandler = new QueryHandler();
                var result       = queryHandler.Execute(ctx.OrderItems, criteria);
                var data         = result.Data.Cast <OrderItem>().ToList();
                Assert.Equal(resultShouldMatch, data);
            });
        }
Ejemplo n.º 8
0
        public async Task Should_get_participant_in_hearing_for_given_hearing_and_participantid()
        {
            participantId = Participants[0].Id;

            var response = await Controller.GetParticipantInHearing(hearingId, participantId);

            response.Should().NotBeNull();
            var objectResult = (OkObjectResult)response;

            objectResult.StatusCode.Should().Be((int)HttpStatusCode.OK);
            var participantResponse = (ParticipantResponse)objectResult.Value;

            participantResponse.Should().NotBeNull();
            participantResponse.DisplayName.Should().Be("Test Participant");
            participantResponse.CaseRoleName.Should().Be("TestCaseRole");
            participantResponse.Id.Should().Be(participantId);
            QueryHandler.Verify(q => q.Handle <GetParticipantsInHearingQuery, List <Participant> >(It.IsAny <GetParticipantsInHearingQuery>()), Times.Once);
        }
Ejemplo n.º 9
0
        public async Task <TResult> Process <TResult>(IQuery <TResult> query) where TResult : IDataView
        {
            var handlerType = typeof(IQueryHandler <,>).MakeGenericType(query.GetType(), typeof(TResult));
            var wrapperType = typeof(QueryHandler <,>).MakeGenericType(query.GetType(), typeof(TResult));

            var handler = _container.GetInstance(handlerType);

            if (handler == null)
            {
                throw new Exception(query.GetType().ToString());
            }

            QueryHandler <TResult> wrappedHandler = (QueryHandler <TResult>)Activator.CreateInstance(wrapperType, handler);

            var result = await wrappedHandler.HandleAsync(query);

            return(result);
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> Shows(GetShowsQuery query)
        {
            // Om het even simpel te houden in de frontend API hebben we een query met side effects gecreeerd in het kader van de 3 urige opdracht.
            try
            {
                var result = await QueryHandler.Handle(query);

                return(Json(result));
            }
            catch (NoShowsException)
            {
                await CommandHandler.Handle(new StoreShowsCommand());

                var result = await QueryHandler.Handle(query);

                return(Json(result));
            }
        }
        public async void Handle_ReturnsCustomer_WhereCustomerExists()
        {
            // Arrange
            var customerData  = fixture.CreateMany <Data.Customer>(1).ToList();
            var testDbContext = new ApplicationDbContextBuilder().WithCustomers(customerData).Build();

            var expectedCustomer = fixture.Create <QueryResult>();

            mockMapper.Setup(x => x.Map <QueryResult>(It.Is <Data.Customer>(y => y.CustomerId == customerData[0].CustomerId))).Returns(expectedCustomer);

            var sut = new QueryHandler(testDbContext, mockMapper.Object);

            // Act
            var actualResult = await sut.Handle(new Query(customerData[0].CustomerId), default(CancellationToken));

            // Assert
            actualResult.Should().BeOfType <QueryResult>()
            .And.BeSameAs(expectedCustomer);
        }
Ejemplo n.º 12
0
        public async Task Should_return_badrequest_for_given_request_with_invalid_representative_details()
        {
            var hearing = GetVideoHearing();

            hearing.Participants[0].HearingRole = new HearingRole(1, "Name")
            {
                UserRole = new UserRole(1, "Representative"),
            };
            participantId = hearing.Participants[0].Id;

            QueryHandler.Setup(q => q.Handle <GetHearingByIdQuery, VideoHearing>(It.IsAny <GetHearingByIdQuery>())).ReturnsAsync(hearing);
            request.Representee = string.Empty;
            var result = await Controller.UpdateParticipantDetails(hearingId, participantId, request);

            result.Should().NotBeNull();
            var objectResult = (BadRequestObjectResult)result;

            objectResult.StatusCode.Should().Be((int)HttpStatusCode.BadRequest);
        }
Ejemplo n.º 13
0
    protected void btnProceed_Click(object sender, EventArgs e)
    {
        String email    = txtEmail.Value;
        String password = txtPassword.Value;

        if (dbcon.ifUserWaiting(email, password))
        {
            errorInfo.Text = "First Admin must accept your registration!";
        }

        else if (email == "" || password == "")
        {
            errorInfo.Text = "Please fill in the details";
        }

        else
        {
            Session["Email"] = email;
            QueryHandler query        = new QueryHandler();
            Boolean      userVerified = dbcon.VerifyUser(email, password);

            if (!userVerified)
            {
                if (query.UserExists(email))
                {
                    txtResetEmail.Value = email;
                    divForgotPassword.Attributes.CssStyle.Add("display", "block");
                    //lblSecurityQuestion.InnerHtml = query.GetSecurityQuestion(email);
                }
                else
                {
                    errorInfo.Text = "Scheduler could not recognize you. If you are first time user sign up";
                }
            }
            else
            {
                Session["userID"]   = query.getUserID(email);
                Session["LoggedIn"] = "true";
                Response.Redirect("usershub.aspx");
            }
        }
    }
Ejemplo n.º 14
0
        public async Task QueryHandler_should_return_a_question()
        {
            var query = new Query()
            {
                Id = 7
            };
            var repo = A.Fake <IRepository>();

            A.CallTo(() => repo.GetQuestionAsync(7)).Returns(new ViewModel.QuestionInputModel()
            {
                Id = 7, Content = "Que"
            });
            var handler = new QueryHandler(repo);

            var result = await handler.Handle(query, CancellationToken.None);

            A.CallTo(() => repo.GetQuestionAsync(7)).MustHaveHappenedOnceExactly();
            result.Question.Id.ShouldBe(7);
            result.Question.Content.ShouldBe("Que");
        }
Ejemplo n.º 15
0
        public static void Citizens(
            QueryHandler <Citizen, uint> h,
            Citizen.Flags flags = Citizen.Flags.Created
            )
        {
            var mgr = Singleton <Cities::CitizenManager> .instance;

            for (int i = 0; i < mgr.m_citizens.m_size; ++i)
            {
                if ((mgr.m_citizens.m_buffer[i].m_flags & flags) == Citizen.Flags.None)
                {
                    continue;
                }

                if (!h.Invoke(ref mgr.m_citizens.m_buffer[i], (uint)i))
                {
                    return;
                }
            }
        }
Ejemplo n.º 16
0
        public async Task QueryHandler_should_return_a_category()
        {
            var query = new Query()
            {
                Id = 1
            };
            var repo = A.Fake <IRepository>();

            A.CallTo(() => repo.GetCategoryAsync(1)).Returns(new ViewModel.CategoryInputModel()
            {
                Id = 1, Name = "Cat"
            });
            var handler = new QueryHandler(repo);

            var result = await handler.Handle(query, CancellationToken.None);

            A.CallTo(() => repo.GetCategoryAsync(1)).MustHaveHappenedOnceExactly();
            result.Category.Id.ShouldBe(1);
            result.Category.Name.ShouldBe("Cat");
        }
Ejemplo n.º 17
0
        public void CanInjectRequestHandlersIntoBroker()
        {
            // Arrange
            var             context        = Fixture.Context;
            ICommandHandler requestHandler = new CommandHandler();
            IQueryHandler   queryHandler   = new QueryHandler(context);

            using var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole());
            var logger = loggerFactory.CreateLogger <RabbitMQServer>();

            // Act
            var rabbitMQServer = new RabbitMQServer(logger);

            rabbitMQServer.Run(requestHandler, queryHandler);

            // Assert
            Assert.Equal(requestHandler, rabbitMQServer.CommandHandler);
            Assert.Equal(queryHandler, rabbitMQServer.QueryHandler);
            rabbitMQServer.Stop();
        }
Ejemplo n.º 18
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <BenchmarkDBContext>(options => {
                options.UseSqlServer(Configuration.GetConnectionString("BdBenchmark"));
            });

            var queryHandler = new QueryHandler(Configuration.GetValue <string>("EndpointServer:HandlerAddress"),
                                                Configuration.GetValue <string>("EndpointServer:ExecutorAddress"));

            services.AddSingleton <ITransport <RouterSocket, DealerSocket> >(queryHandler);

            services.AddScoped <IDependencyResolver, AspNetCoreDependencyResolver>();
            //services.AddScoped<IGetAllProductsHandler, GetAllProductsHandler>();
            services.AddScoped <QueryExecutor <GetAllProducts, IEnumerable <Product> >, GetAllProductsHandler>();

            services.AddScoped <IOutputTransport>(s =>
                                                  new SharedKernel.Distribuited.ClientHandler(Configuration.GetValue <string>("EndpointServer:ExecutorAddress")));

            services.AddControllers();
        }
Ejemplo n.º 19
0
        public void Simple()
        {
            MockContextFactory.SeedAndTestContextFor("SortTests_Simple", TestSeeders.SimpleSeedScenario, ctx =>
            {
                var shouldResult = ctx.Orders.OrderBy(t => t.OrderNum).ToList();

                // query handler that is empty should be the same as running to list.
                var criteria = new QueryCriteria()
                {
                    Sorts = new List <ISort>()
                    {
                        new Sort("OrderNum")
                    }
                };

                var queryHandler = new QueryHandler();
                var result       = queryHandler.Execute(ctx.Orders, criteria);
                Assert.Equal(shouldResult, result.Data.Cast <Order>().ToList());
            });
        }
Ejemplo n.º 20
0
        public void GroupComplex()
        {
            MockContextFactory.SeedAndTestContextFor("GroupTests_Complex", TestSeeders.SeedTicketScenario, ctx =>
            {
                var criteria = new QueryCriteria()
                {
                    Groups = new List <IGroup>()
                    {
                        new Group {
                            Path = "TicketType"
                        },
                        new Group {
                            Path = "Priority"
                        }
                    },
                    Aggregates = new List <IAggregate>()
                    {
                        new Aggregate {
                            Type = AggregateType.Count
                        }
                    }
                };

                var queryHandler = new QueryHandler(Enumerable.Empty <IQueryInterceptorProvider>());
                var result       = queryHandler.Execute(ctx.Tickets, criteria, new QueryExecutionOptions
                {
                    GroupByInMemory = true
                });

                var groupedResult = result.GroupedResult();

                var firstGroup = groupedResult.Groups.FirstOrDefault();
                Assert.NotNull(firstGroup);
                var secondGroup = groupedResult.Groups.Skip(1).FirstOrDefault();
                Assert.NotNull(secondGroup);

                var expected = ctx.Tickets.Select(t => t.TicketType).Distinct().Count();
                var c        = groupedResult.Groups.Select(t => t.GroupValue).Count();
                Assert.Equal(expected, c);
            });
        }
Ejemplo n.º 21
0
            public async Task ReturnPlayerFeedbacks_WhenValidFilterIsGiven()
            {
                var rawFilter = new RawFilter
                {
                    MinRating = 3,
                    MaxRating = 3
                };

                _mockFeedbackRepository
                .Setup(repo => repo.GetLatestBy(It.IsAny <QueryFilter>()))
                .ReturnsAsync(new [] { _playerFeedback });

                var queryHandler = new QueryHandler(_mockFeedbackRepository.Object);

                var result = await queryHandler.GetLatestFeedBack(rawFilter);

                var expectedResult = new[] { _playerFeedback }.AsEnumerable();

                Assert.True(result.IsOk);
                Assert.Equal(expectedResult, result.Value);
            }
Ejemplo n.º 22
0
        public void Can_Retrieve_Requests_WithStatus()
        {
            // arrange
            var keys    = new string[] { "Query", "Status" }; // keys in response
            var length  = keys.Length;
            var handler = new QueryHandler(Fixture.Context);
            var args    = new Dictionary <string, string>()
            {
                { "Status", RequestStatus.Submitted.ToString() }
            };
            // act
            var result     = handler.QueryFor(Queries.WithStatus, args);
            var resultDict = JsonSerializer.Deserialize <Dictionary <string, string> >(result);

            // assert
            foreach (var s in keys)
            {
                resultDict.Should().ContainKey(s);
            }
            resultDict.Keys.Count.Should().BeGreaterThan(3);
        }
        public void Simple()
        {
            MockContextFactory.SeedAndTestContextFor("GroupInterceptorTests_Simple", TestSeeders.SimpleSeedScenario, ctx =>
            {
                var expected = ctx.Orders
                               .OrderBy(t => t.Customer.FirstName)
                               .GroupBy(t => t.Customer.FirstName)
                               .Select(t => t.Key)
                               .ToList();

                var criteria = new QueryCriteria();
                criteria.Groups.Add(new Group {
                    Path = "CustomerFirstName"
                });
                var queryHandler = new QueryHandler();
                queryHandler.AddInterceptor(new MockGroupInterceptor());
                var result = queryHandler.Execute(ctx.Orders, criteria);
                var actual = result.Data.Cast <IGroupQueryResult>().Select(t => t.GroupValue).ToList();
                Assert.Equal(expected, actual);
            });
        }
Ejemplo n.º 24
0
        public void SortInterceptor()
        {
            MockContextFactory.SeedAndTestContextFor("SortTests_SortInterceptor", TestSeeders.SimpleSeedScenario, ctx =>
            {
                var shouldResult = ctx.Orders.OrderByDescending(t => t.OrderNum).ToList();

                // query handler that is empty should be the same as running to list.
                var criteria = new QueryCriteria()
                {
                    Sorts = new List <ISort>()
                    {
                        new Sort("OrderNumStr", false)
                    }
                };

                var queryHandler = new QueryHandler(Enumerable.Empty <IQueryInterceptorProvider>());
                queryHandler.AddInterceptor(new MockSortInterceptor());
                var result = queryHandler.Execute(ctx.Orders, criteria);
                Assert.Equal(shouldResult, result.Data);
            });
        }
Ejemplo n.º 25
0
        public async Task QueryHandler_should_return_category_list()
        {
            var query = new Query();
            var repo  = A.Fake <IRepository>();

            A.CallTo(() => repo.GetCategoriesAsync()).Returns(new List <ViewModel.CategoryInputModel>
            {
                new ViewModel.CategoryInputModel {
                    Id = 5, Name = "Cat1"
                },
                new ViewModel.CategoryInputModel {
                    Id = 6, Name = "Cat2"
                }
            });
            var handler = new QueryHandler(repo);

            var result = await handler.Handle(query, CancellationToken.None);

            A.CallTo(() => repo.GetCategoriesAsync()).MustHaveHappenedOnceExactly();
            result.Categories.ToList().Count.ShouldBe(2);
        }
Ejemplo n.º 26
0
        public void Simple()
        {
            MockContextFactory.SeedAndTestContextFor("AggregatorInterceptorTests_Simple", TestSeeders.SimpleSeedScenario, ctx =>
            {
                var expected = ctx.OrderItems.GroupBy(t => true).Select(t => new
                {
                    PriceAtTheTime = t.Average(t2 => t2.Item.Price)
                }).First();

                var criteria = new QueryCriteria();
                criteria.Aggregates.Add(new Aggregate
                {
                    Type = AggregateType.Avg,
                    Path = "ItemPrice"
                });
                var queryHandler = new QueryHandler();
                queryHandler.AddInterceptor(new MockAggregateInterceptor());
                var result = queryHandler.Execute(ctx.OrderItems, criteria);
                Assert.Equal(expected.PriceAtTheTime, result.Aggregates.First().Value);
            });
        }
Ejemplo n.º 27
0
        public void MultiSort()
        {
            MockContextFactory.SeedAndTestContextFor("SortTests_MultiSort", TestSeeders.SimpleSeedScenario, ctx =>
            {
                var shouldResult = ctx.Orders.OrderBy(t => t.Customer.FirstName).ThenBy(t => t.OrderNum).ToList();

                // query handler that is empty should be the same as running to list.
                var criteria = new QueryCriteria()
                {
                    Sorts = new List <ISort>()
                    {
                        new Sort("Customer.FirstName"),
                        new Sort("OrderNum")
                    }
                };

                var queryHandler = new QueryHandler(Enumerable.Empty <IQueryInterceptorProvider>());
                var result       = queryHandler.Execute(ctx.Orders, criteria);
                Assert.Equal(shouldResult, result.Data);
            });
        }
Ejemplo n.º 28
0
        public async Task Test_ConnectionManagement_WithQueryHandler()
        {
            var connection1 = new SqliteConnection(DatabaseHelper.TestDbConnectionString);
            var connection2 = new SqliteConnection(DatabaseHelper.TestDbConnectionString);

            try
            {
                QueryOptions options1 = new QueryOptions()
                {
                    ConnectionFactory = () => connection1,
                    Schemas           = DatabaseHelper.Default.Schemas,
                };

                QueryOptions options2 = new QueryOptions()
                {
                    ConnectionFactory = () => connection2,
                    Schemas           = DatabaseHelper.Default.Schemas,
                };

                QueryHandler handler1 = new QueryHandler(options1);
                QueryHandler handler2 = new QueryHandler(options2);

                handler1.List <int>(new QueryData()
                {
                    QueryText = "SELECT 0 AS [Item];"
                });
                await handler2.ListAsync <int>(new QueryData()
                {
                    QueryText = "SELECT 0 AS [Item];"
                });

                connection1.State.ShouldBe(ConnectionState.Closed);
                connection2.State.ShouldBe(ConnectionState.Closed);
            }
            finally
            {
                connection1.Dispose();
                connection2.Dispose();
            }
        }
Ejemplo n.º 29
0
        public void MoreComplexCompositeFilter()
        {
            MockContextFactory.SeedAndTestContextFor("FilterTests_MoreComplexCompositeFilter", TestSeeders.SimpleSeedScenario, ctx =>
            {
                var resultShouldMatch = ctx.Customers.Where(t => (t.FirstName == "John" || t.LastName == "Norris") && t.FirstName.Contains("o")).ToList();

                var criteria = new QueryCriteria()
                {
                    Filters = new List <IFilter>
                    {
                        new CompositeFilter()
                        {
                            Type    = FilterType.Composite,
                            Filters = new List <IFilter>
                            {
                                new SimpleFilter()
                                {
                                    Path = "FirstName", Type = FilterType.Equal, Value = "John"
                                },
                                new SimpleFilter()
                                {
                                    Path = "LastName", Type = FilterType.Equal, Value = "Norris"
                                }
                            }
                        },
                        new SimpleFilter()
                        {
                            And   = true,
                            Path  = "FirstName",
                            Type  = FilterType.Contains,
                            Value = "o"
                        }
                    }
                };

                var queryHandler = new QueryHandler(Enumerable.Empty <IQueryInterceptorProvider>());
                var result       = queryHandler.Execute(ctx.Customers, criteria);
                Assert.Equal(resultShouldMatch, result.Data);
            });
        }
Ejemplo n.º 30
0
    protected void btnProceed_Click(object sender, EventArgs e)
    {
        String email    = txtEmail.Value;
        String password = txtPassword.Value;

        if (email == "" || password == "")
        {
            errorInfo.Text = "Please fill in the details";
        }
        else
        {
            Session["Email"] = email;
            QueryHandler query        = new QueryHandler();
            Boolean      userVerified = query.VerifyUser(email, password);

            if (!userVerified)
            {
                if (query.UserExists(email))
                {
                    txtResetEmail.Value = email;
                    divForgotPassword.Attributes.CssStyle.Add("display", "block");
                    lblSecurityQuestion.InnerHtml = query.GetSecurityQuestion(email);
                }
                else
                {
                    errorInfo.Text = "Scheduler could not recognize you. If you are a first time user please sign up";
                }
            }
            else
            {
                string userDetails = query.GetUserDetails(email, password);

                Session["Firstname"] = userDetails.Split(' ')[0];
                Session["Fullname"]  = userDetails;
                Session["LoggedIn"]  = "ture";
                Response.Redirect("usershub.aspx");
            }
        }
    }
Ejemplo n.º 31
0
        public void ClientDealer_VentilatorRouter_ProcessorsRouter()
        {
            var endpointCommand = "inproc://127.0.0.1:5000";
            var endpointQuery   = "inproc://127.0.0.1:5001";

            var endpointVentilator = "inproc://127.0.0.1:5100";


            var queryExecutor = new QueryExecutor(endpointQuery, null);

            Task.Delay(1000);

            var queryHandler = new QueryHandler(endpointVentilator, endpointQuery);

            Task.Delay(5000);

            var client = new ClientHandler(endpointVentilator);

            Task.Delay(1000);

            client.Send("TESTE");
        }
Ejemplo n.º 32
0
        public void Simple()
        {
            MockContextFactory.SeedAndTestContextFor("GroupTests_Simple", TestSeeders.SimpleSeedScenario, ctx =>
            {
                var shouldResult = ctx.Orders.OrderBy(t => t.Customer).GroupBy(t => t.Customer).Select(t => new
                {
                    Customer = t.Key,
                    Orders   = t.ToList()
                }).ToList();

                // query handler that is empty should be the same as running to list.
                var criteria = new QueryCriteria()
                {
                    Groups = new List <IGroup>
                    {
                        new Group {
                            Path = "Customer"
                        }
                    }
                };

                var queryHandler = new QueryHandler();
                var result       = queryHandler.Execute(ctx.Orders, criteria);

                var data = result.Data.Cast <Order>().ToList();
                // top level should have same amount of group levels.
                Assert.Equal(data.Count, shouldResult.Count);
                for (var i = 0; i < shouldResult.Count; i++)
                {
                    var expected = shouldResult[0];
                    var actual   = ((IGroupQueryResult)result.Data[0]);
                    Assert.Equal(expected.Customer.Id, (actual.GroupValue as Customer).Id);

                    var expectedOrderIds = expected.Orders.Select(t => t.Id).ToList();
                    var actualOrderIds   = actual.Data.Cast <Order>().Select(t => t.Id).ToList();
                    Assert.Equal(expectedOrderIds, actualOrderIds);
                }
            });
        }
Ejemplo n.º 33
0
 public QueryDialog(QueryHandler handler)
 {
     InitializeComponent();
     queryHandler = handler;
 }
 public Query(QueryHandler queryCallback)
 {
     this.queryCallback = queryCallback;
 }
Ejemplo n.º 35
0
 public Query(Dictionary<String, Object> queryInput, QueryHandler queryCallback)
 {
     this.queryInput = queryInput;
     this.queryCallback = queryCallback;
 }
Ejemplo n.º 36
0
 public void DoQuery(Dictionary<String, Object> query, QueryHandler queryHandler)
 {
     Guid requestId = Guid.NewGuid();
     queries.Add(requestId, new Query(query, queryHandler));
     query.Add("requestId", requestId);
     Request("/service/query", new Dictionary<String, Object>() { { "data", query } });
 }