Exemple #1
0
        public async Task IF_not_admin_user_SHOULD_fail()
        {
            //Act
            var result = await Sut.HandleAsync(Command, User);

            //Assert
            result.VerifyResponseError(AuthError.NotAuthorized, MockAnalyticsService);
            Assert.That(DbContextAfter.Set <TEntity>().First(x => x.Id == GrainId).EntityState, Is.Not.EqualTo(EntityState.Archived));
        }
        public async Task IF_not_Draft_or_Archived_SHOULD_fail(EntityState invalidState)
        {
            //Arrange
            ExistingEntityBuilder.With(x => x.EntityState, invalidState);

            //Act
            var result = await Sut.HandleAsync(Command, AdminUser);

            //Assert
            result.VerifyResponseError(DomainErrors.InvalidEntityState(invalidState), MockAnalyticsService);
            Assert.That(DbContextAfter.Set <TEntity>().First(x => x.Id == GrainId).EntityState, Is.Not.EqualTo(EntityState.Draft));
        }
Exemple #3
0
        public async Task IF_Active_SHOULD_Activate(EntityState validState)
        {
            //Arrange
            ExistingEntityBuilder.With(x => x.EntityState, validState);

            //Act
            var result = await Sut.HandleAsync(Command, AdminUser);

            //Assert
            Assert.That(result.IsSuccess);
            var modifiedEntity = DbContextAfter.Set <TEntity>().First(x => x.Id == GrainId);

            Assert.That(modifiedEntity.ModifiedAt, Is.EqualTo(RunTime));
            Assert.That(modifiedEntity.EntityState, Is.EqualTo(EntityState.Archived));
        }