Exemple #1
0
        public async Task Create_should_create_domain_object()
        {
            var context = CreateContextForCommand(new CreateApp {
                Name = AppName, AppId = AppId
            });

            await TestCreate(app, async _ =>
            {
                await sut.HandleAsync(context);
            });

            Assert.Equal(AppId, context.Result <EntityCreatedResult <Guid> >().IdOrValue);
        }
Exemple #2
0
        public async Task Create_should_throw_exception_if_a_name_with_same_name_already_exists()
        {
            var context = CreateContextForCommand(new CreateApp {
                Name = AppName, AppId = AppId
            });

            A.CallTo(() => appRepository.FindAppAsync(AppName))
            .Returns(A.Dummy <IAppEntity>());

            await TestCreate(app, async _ =>
            {
                await Assert.ThrowsAsync <ValidationException>(async() => await sut.HandleAsync(context));
            }, false);

            A.CallTo(() => appRepository.FindAppAsync(AppName)).MustHaveHappened();
        }