コード例 #1
0
        public ApplicationIdNotPartOfOrganisationException NewCollectionWithApplicationIdNotPartOfOrganisationId()
        {
            Organisation organisationThatIsNotTheOneForTheApplication = new Api().Resource<OrganisationResource>().NewOrganisation();

            ApplicationResource applicationResource = new Api().Resource<ApplicationResource>();
            var applicationWeWantToAddCollectionTo = applicationResource.NewApplication();
            var applicationIdForOneWeWantToAddCollectionTo = applicationWeWantToAddCollectionTo.Id;

            var organisationIdDifferentToApplicationWeWantToAddTo = organisationThatIsNotTheOneForTheApplication.Id;

            try
            {
                _collectionServiceAgent.Post(
                    new Collection
                        {
                            Name = "testNameForBadOrganisationId",
                            Active = true,
                            ApplicationId = applicationIdForOneWeWantToAddCollectionTo,
                            OrganisationId = organisationIdDifferentToApplicationWeWantToAddTo
                        });
            }
            catch (ApplicationIdNotPartOfOrganisationException exception)
            {
                return exception;
            }

            return null;
        }
コード例 #2
0
        public BadRequestException NewCollectionWithUnspecifiedName()
        {
            ApplicationResource applicationResource = new Api().Resource<ApplicationResource>();
            var application = applicationResource.NewApplication();
            var applicationId = application.Id;
            var organisationId = application.OrganisationId;

            try
            {
                _collectionServiceAgent.Post(
                    new Collection
                    {
                        Active = true,
                        ApplicationId = applicationId,
                        OrganisationId = organisationId,
                    });
            }
            catch (BadRequestException ex)
            {
                return ex;
            }

            throw new SpecFlowException("Expected BadRequestException was not caught");
        }
コード例 #3
0
        public Collection NewCollectionWithSpecifiedName(string name)
        {
            var applicationResource = new Api().Resource<ApplicationResource>();
            var newApplication = applicationResource.NewApplication();
            var applicationId = newApplication.Id;
            var organisationId = newApplication.OrganisationId;

            return NewCollectionWithSpecifiedNameAndApplicationIdAndOrganisationId(name, applicationId, organisationId);
        }
コード例 #4
0
        public BadRequestException NewCollectionWithNoOrganisationId()
        {
            ApplicationResource applicationResource = new Api().Resource<ApplicationResource>();
            var application = applicationResource.NewApplication();
            var applicationId = application.Id;

            try
            {
                _collectionServiceAgent.Post(
                    new Collection
                    {
                        Name = "testNameForNoOrganisationId",
                        Active = true,
                        ApplicationId = applicationId,
                    });
            }
            catch (BadRequestException exception)
            {
                return exception;
            }

            throw new SpecFlowException("Expected BadRequestException was not caught");
        }
コード例 #5
0
        public OrganisationIdNotValidException NewCollectionWithNonExistentOrganisationId()
        {
            ApplicationResource applicationResource = new Api().Resource<ApplicationResource>();
            var application = applicationResource.NewApplication();
            var applicationId = application.Id;

            try
            {
                _collectionServiceAgent.Post(
                    new Collection
                    {
                        Name = "testNameForNoOrganisationId",
                        Active = true,
                        ApplicationId = applicationId,
                        OrganisationId = applicationId + "xx"
                    });
            }
            catch (OrganisationIdNotValidException exception)
            {
                return exception;
            }

            return null;
        }
コード例 #6
0
        public CollectionNameAlreadyExistsException NewCollectionWithExistingNameInApplication()
        {
            ApplicationResource applicationResource = new Api().Resource<ApplicationResource>();
            var application = applicationResource.NewApplication();
            var applicationId = application.Id;
            var organisationId = application.OrganisationId;

            string collectionNameToBeDuplicated = "testNameForCollection" + DateTime.UtcNow.ToString("yyyyMMddSSmm");
            _collectionServiceAgent.Post(
                new Collection
                    {
                        Name = collectionNameToBeDuplicated,
                        Active = true,
                        ApplicationId = applicationId,
                        OrganisationId = organisationId
                    });

            try
            {
                _collectionServiceAgent.Post(
                    new Collection
                    {
                        Name = collectionNameToBeDuplicated,
                        Active = true,
                        ApplicationId = applicationId,
                        OrganisationId = organisationId
                    });
            }
            catch (CollectionNameAlreadyExistsException exception)
            {
                return exception;
            }

            throw new SpecFlowException("Did not get expected CollectionNameAlreadyExistsException");
        }