Example #1
0
        public async Task CheckThat_SessionWithNoSchedule_IsRequested()
        {
            var person         = PersonId.New();
            var start          = default(DateTimeOffset?);
            var end            = default(DateTimeOffset?);
            var repository     = new FakeSessionStore();
            var sessionQueries = new FakePersonProjectionStore();

            sessionQueries.AddPerson(person, "John Doe");
            var command = new RequestSession(new[] { person }, "super session", "Ca va etre chouette", new[] { "super", "chouette" }, start, end);
            var sut     = new RequestSessionCommandHandler(repository, sessionQueries);

            var(result, events) = await sut.ExecuteAsync(command);

            Check.That(result).InheritsFrom <SuccessCommandResult>();
            Check.That(events).CountIs(1);
            Check.That(events[0]).IsInstanceOf <SessionRequested>();
            var sessionRequestedEvent = (SessionRequested)events[0];
            var session = repository.Sessions[sessionRequestedEvent.Id];

            Check.That(session.Speakers).IsEquivalentTo(command.Speakers);
            Check.That(session.Title).IsEqualTo(command.Title);
            Check.That(session.Description).IsEqualTo(command.Description);
            Check.That(session.Tags).IsEquivalentTo(command.Tags);
            Check.That(session.Schedule).IsNull();
            Check.That(session.Status).IsEqualTo(SessionStatus.Requested);
        }
Example #2
0
        protected virtual void ConfigureTestServices(IServiceCollection services)
        {
            var personProjectionStore = new FakePersonProjectionStore();

            personProjectionStore.AddPerson(TestAuthenticationHandler.UserPersonId, "John TheUser");
            services.AddSingleton(personProjectionStore);
            services.AddTransient <IPersonProjectionStore>(p => p.GetRequiredService <FakePersonProjectionStore>());

            services.AddAuthentication(TestAuthenticationHandler.TestScheme)
            .AddScheme <AuthenticationSchemeOptions, TestAuthenticationHandler>(TestAuthenticationHandler.TestScheme, o => { });
        }
Example #3
0
        public async Task CheckThat_SessionWithNoEnd_IsFailed()
        {
            var start          = new DateTimeOffset(2020, 1, 1, 0, 0, 0, TimeSpan.Zero);
            var end            = default(DateTimeOffset?);
            var repository     = new FakeSessionStore();
            var sessionQueries = new FakePersonProjectionStore();
            var command        = new RequestSession(new[] { PersonId.New() }, "super session", "Ca va etre chouette", new[] { "super", "chouette" }, start, end);
            var sut            = new RequestSessionCommandHandler(repository, sessionQueries);

            var(result, events) = await sut.ExecuteAsync(command);

            Check.That(result).InheritsFrom <ValidationFailureCommandResult>();
            Check.That(((FailureCommandResult)result).Reason).IsEqualTo("Schedule is invalid: End time cannot be null (Parameter 'endTime').");
            Check.That(events).CountIs(0);
            Check.That(repository.Sessions).CountIs(0);
        }
Example #4
0
        public async Task CheckThat_SessionWithUnknownSpeaker_IsFailed()
        {
            var person         = PersonId.New();
            var start          = default(DateTimeOffset?);
            var end            = default(DateTimeOffset?);
            var repository     = new FakeSessionStore();
            var sessionQueries = new FakePersonProjectionStore();
            var command        = new RequestSession(new[] { person }, "super session", "Ca va etre chouette", new[] { "super", "chouette" }, start, end);
            var sut            = new RequestSessionCommandHandler(repository, sessionQueries);

            var(result, events) = await sut.ExecuteAsync(command);

            Check.That(result).InheritsFrom <ValidationFailureCommandResult>();
            Check.That(((ValidationFailureCommandResult)result).Reason).IsEqualTo($"Speakers are invalid: unknown speakers");
            Check.That(((ValidationFailureCommandResult)result).Reason).IsEqualTo($"Speakers are invalid: unknown speakers");
            Check.That(events).CountIs(0);
            Check.That(repository.Sessions).CountIs(0);
        }