protected override void Before()
        {
            FakeConnectionFactory cf = new FakeConnectionFactory();

            request = new IconUploadRequest(cf,
                                            WebsiteState, IconValidatorService,
                                            new FakeFileReceiver(1, "Test File"));

            Icon existingIcon = new Icon()
            {
                Id    = 5,
                Name  = "Test Icon",
                Image = "png",
                Link  = "a.com/b"
            };

            cf.IconInternal.Init(existingIcon);

            Icon icon = new Icon()
            {
                Name  = "Test Icon",
                Image = "png",
                Link  = "a.com"
            };

            post = new IconPost()
            {
                Id   = -1,
                Name = "Test Icon",
                Link = "a.com"
            };
        }
Пример #2
0
        protected override void Before()
        {
            FakeConnectionFactory cf      = new FakeConnectionFactory();
            IconUploadRequest     request = new IconUploadRequest(cf,
                                                                  WebsiteState, IconValidatorService, new FakeEmptyFileReceiver());

            cf.IconInternal.Init(new Icon()
            {
                Id    = EXISTING_ID,
                Name  = EXISTING_NAME,
                Image = EXISTING_IMAGE,
                Link  = EXISTING_LINK
            });

            IconPost post = new IconPost()
            {
                Id   = EXISTING_ID,
                Name = EXISTING_NAME,
                Link = NEW_LINK
            };

            request.Process(post);

            newIcon = cf.IconInternal.Records.Single();
            history = cf.IconHistoryInternal.Records.Single();
        }
Пример #3
0
        public Icon UpdateIcon()
        {
            IconPost icon = ParseFormData <IconPost>();

            return(Process(() => {
                return Get <IconUploadRequest>().Process(icon);
            }));
        }
        public void ValidateIconPost(IconPost iconPost) {
            if (string.IsNullOrWhiteSpace(iconPost.Name))
                throw new PortalException(IconResult.FAIL_NO_NAME, "Name must have a value.");
            if (string.IsNullOrWhiteSpace(iconPost.Link))
                throw new PortalException(IconResult.FAIL_NO_LINK, "Link must have a value.");
            if (iconPost.Name.Length > 30)
                throw new PortalException(IconResult.FAIL_LONG_NAME, "Name length must be less than 30 characters.");
            if (iconPost.Link.Length > 500)
                throw new PortalException(IconResult.FAIL_LONG_LINK, "Link length must be less than 500 characters.");

            string nameWithOnlyValidChars = Regex.Replace(iconPost.Name, @"[^a-zA-Z0-9 ]", "");
            if (iconPost.Name != nameWithOnlyValidChars)
                throw new PortalException(IconResult.FAIL_INVALID_NAME, "Name must only have letters, numbers, and spaces.");
        }
Пример #5
0
        protected override void Before()
        {
            FakeConnectionFactory cf = new FakeConnectionFactory();

            request = new IconUploadRequest(cf,
                                            WebsiteState, IconValidatorService,
                                            new FakeEmptyFileReceiver());

            post = new IconPost()
            {
                Id   = -1,
                Name = "test icon",
                Link = "a.com/b"
            };
        }
Пример #6
0
        protected override void Before()
        {
            FakeConnectionFactory cf = new FakeConnectionFactory();

            fileReceiver = new FakeFileReceiver(1, "Test File");
            IconUploadRequest request = new IconUploadRequest(cf,
                                                              WebsiteState, IconValidatorService, fileReceiver);

            IconPost post = new IconPost()
            {
                Id   = -1,
                Name = "test icon",
                Link = LINK
            };

            request.Process(post);

            newIcon = cf.IconInternal.Records.Single();
            history = cf.IconHistoryInternal.Records.Single();
        }