internal void Test(TestServices services, EmployeesQuery q, Ref <Employee> employee, IReadOnlyCollection <EmployeeRM> result) { GIVEN["a query"] = () => { services = new TestServices(b => b .Services(c => c.RegisterType <EmployeesQuery>().AsImplementedInterfaces()) .UseDefaults()); q = new EmployeesQuery(services.GetRequiredService <IEventStore>()); var e = new Employee(ID.NewID(), "Test employee"); services.Save(e); employee = e; EmployeeCodes ec = new EmployeeCodes(); ec.AssignCode(employee, "1234"); services.Save(ec); }; WHEN["running the query"] = () => result = q.Run(services.GetRequiredService <IContext>()); THEN["the result is correct"] = () => result.Should().BeEquivalentTo(new EmployeeRM(employee) { Code = "1234", Name = "Test employee" }); WHEN["running the query via container"] = () => result = services.RunQuery(new GetEmployees()).Result; THEN["it returns the result"] = () => result.Should().NotBeEmpty(); }