Пример #1
0
 public async Task NotDeleteOrganizationsThatDoNotMatchOrganizationIdOnCommand()
 {
     var command = new DeleteOrganization { Id = 999 };
     var handler = new DeleteOrganizationHandler(Context);
     await handler.Handle(command);
     Assert.Equal(2, Context.Organizations.Count());
 }
        public void DeleteOrganization_Action_Fails()
        {
            // Arrange
            var organizationDto = TestHelper.OrganizationDto();

            GenericServiceResponse <bool> fakeResponse = null;

            mockClientServicesProvider.Setup(x => x.Logger).Returns(mockLogger.Object).Verifiable();
            mockClientServicesProvider.Setup(x => x.OrganizationService.DeleteOrganization(organizationDto)).Returns(fakeResponse).Verifiable();

            var viewModel = new GenericViewModel();

            var action = new DeleteOrganization <GenericViewModel>(mockClientServicesProvider.Object)
            {
                OnComplete = model => viewModel = model
            };

            // Act
            var result = action.Invoke(organizationDto);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(GenericViewModel));
            Assert.IsNotNull(result.Notifications);
            Assert.IsInstanceOfType(result.Notifications, typeof(NotificationCollection));
            Assert.IsTrue(result.Notifications.Count() == 1);
            Assert.IsTrue(result.HasErrors);
            Assert.IsNotNull(result.Success);
            Assert.IsInstanceOfType(result.Success, typeof(bool));
            Assert.IsFalse(result.Success);
        }
Пример #3
0
 public async Task DeleteOrganizationThatMatchesOrganizationIdOnCommand()
 {
     var command = new DeleteOrganization { Id = 1 };
     var handler = new DeleteOrganizationHandler(Context);
     await handler.Handle(command);
     var data = Context.Organizations.Count(_ => _.Id == 1);
     Assert.Equal(0, data);
 }
        public async Task DeleteTheOrganization()
        {
            var command = new DeleteOrganization {
                Id = 1
            };

            var handler = new DeleteOrganizationHandler(Context);
            await handler.Handle(command);

            Assert.False(Context.Organizations.Any(x => x.Id == command.Id));
        }
Пример #5
0
        public void Delete(DeleteOrganization request)
        {
            var user = GetUser();

            AssertOrganizationOwner(Db, request.Id, user, out var org, out var orgMember);

            Db.UpdateOnly(() => new Organization
            {
                Deleted   = DateTime.Now,
                DeletedBy = user.UserName,
            },
                          where : x => x.Id == request.Id);

            ClearOrganizationCaches();
        }
Пример #6
0
 public object Any(DeleteOrganization request)
 {
     return(DeleteOrganization(request.id));
 }