Пример #1
0
        public async Task Projection_Query()
        {
            var airline = await j.Fact(new Airline("IA"));

            var user = await j.Fact(new User("--- PUBLIC KEY ---"));

            var passenger = await j.Fact(new Passenger(airline, user));

            await j.Fact(new PassengerName(passenger, "Joe", new PassengerName[0]));

            var passengers = await j.Query(airline, Given <Airline> .Match((airline, facts) =>
                                                                           from passenger in facts.OfType <Passenger>()
                                                                           where passenger.airline == airline
                                                                           select new
            {
                passenger,
                names = facts.All(passenger, namesOfPassenger)
            }
                                                                           ));

            var result = passengers.Should().ContainSingle().Subject;

            result.names.Should().ContainSingle().Which
            .value.Should().Be("Joe");
        }
Пример #2
0
        public async Task Watch_NoResults()
        {
            var company = await j.Fact(new Company("Contoso"));

            var officeObserver = j.Watch(company, officesInCompany,
                                         async office => await officeRepository.Insert(office)
                                         );
            await officeObserver.Initialized;

            await officeObserver.Stop();

            officeRepository.Items.Should().BeEmpty();
        }
Пример #3
0
        public async Task CanQueryForPredecessors()
        {
            var flight = await j.Fact(new Flight(new AirlineDay(new Airline("IA"), DateTime.Today), 4272));

            var cancellation = await j.Fact(new FlightCancellation(flight, DateTime.UtcNow));

            var specification = Given <FlightCancellation> .Match(
                flightCancellation => flightCancellation.flight
                );

            var flights = await j.Query(cancellation, specification);

            flights.Should().ContainSingle().Which.Should().BeEquivalentTo(flight);
        }