예제 #1
0
        public void IdFromUrl_good_value()
        {
            ids = new Ids(logger.Object);
            var returned = ids.IdFromUrl("http://google.com");

            Assert.AreEqual("aa2239c17609b21eba034c564af878f3eec8ce83ed0f2768597d2bc2fd4e4da5", returned,
                            "Returned value didn't match the SHA256 generated via http://www.xorbin.com/tools/sha256-hash-calculator");
            logger.Verify();
        }
예제 #2
0
        public void IdFromUrl_empty_url()
        {
            logger.Setup(x => x.Error(It.IsAny <string>(), null, null));
            ids = new Ids(logger.Object);
            var returned = ids.IdFromUrl("");

            Assert.IsNull(returned, "The returned value should have been null");
            logger.Verify();
        }
예제 #3
0
        public void ExtractIdFromTypeAndId_empty_after_splitting()
        {
            const string typeAndId = "t1_  ";

            logger.Setup(x => x.Error(It.IsAny <string>(), null, null));
            ids = new Ids(logger.Object);
            var returned = ids.ExtractIdFromTypeAndId(typeAndId);

            Assert.IsNull(returned, $"Expected a null value, somehow got a real one [{returned}]");
            logger.Verify();
        }
예제 #4
0
        public void ExtractIdFromTypeAndId_expected_success()
        {
            const string typeAndId = "t1_dmjuw52";
            const string expected  = "dmjuw52";

            ids = new Ids(logger.Object);
            var returned = ids.ExtractIdFromTypeAndId(typeAndId);

            Assert.AreEqual(expected, returned, $"{expected} did not match {returned}");
            logger.Verify();
        }
예제 #5
0
        public void SubredditIdFromUrl_url_noWWW()
        {
            const string url =
                "https://reddit.com/r/Hawaii/comments/6z7mcz/eli5_molokai_ranch_which_covers_about_35_of_the/";

            logger.Setup(x => x.Info(It.IsAny <string>(), It.IsAny <string>()));
            ids = new Ids(logger.Object);
            var result = ids.ExtractSubredditIdFromUrl(url);

            Assert.AreEqual("Hawaii", result);
        }
예제 #6
0
        public void ExtractIdFromTypeAndId_not_enough_underscores()
        {
            const string typeAndId = "dmjuw52";

            logger.Setup(x => x.Error(It.IsAny <string>(), null, null));
            ids = new Ids(logger.Object);
            var returned = ids.ExtractIdFromTypeAndId(typeAndId);

            Assert.IsNull(returned, $"Expected a null value, somehow got a real one [{returned}]");
            logger.Verify();
        }
예제 #7
0
        public void PostUrlFromChildDetails_empty_url()
        {
            const string childUrl = "";
            const string childId  = "dmo8j8n";

            logger.Setup(x => x.Error(It.IsAny <string>(), null, null));
            ids = new Ids(logger.Object);
            var returned = ids.PostUrlFromChildDetails(childUrl, childId);

            Assert.IsNull(returned, $"Expected a null value, somehow got a real one [{returned}]");
            logger.Verify();
        }
예제 #8
0
        public void PostUrlFromChildDetails_child_id_not_in_url()
        {
            const string childUrl =
                "https://www.reddit.com/r/Competitiveoverwatch/comments/6xzuk2/doomfists_new_hitbox_analysis_xpost_from/";
            const string childId = "dmo8j8n";

            logger.Setup(x => x.Error(It.IsAny <string>(), null, null));
            ids = new Ids(logger.Object);
            var returned = ids.PostUrlFromChildDetails(childUrl, childId);

            Assert.IsNull(returned, $"Expected a null value, somehow got a real one [{returned}]");
            logger.Verify();
        }
예제 #9
0
        public void ParentUrlFromChildDetails_null_child_url()
        {
            logger.Setup(x => x.Error(It.IsAny <string>(), null, null));
            ids = new Ids(logger.Object);
            var returned = ids.ParentUrlFromChildDetails(
                childUrl: null,
                childId: "dmo8j8n",
                parentId: "dmjuw52"
                );

            Assert.IsNull(returned, "The returned value should have been null");
            logger.Verify();
        }
예제 #10
0
        public void ParentUrlFromChildDetails_null_child_id()
        {
            logger.Setup(x => x.Error(It.IsAny <string>(), null, null));
            ids = new Ids(logger.Object);
            var returned = ids.ParentUrlFromChildDetails(
                childUrl:
                "https://www.reddit.com/r/Competitiveoverwatch/comments/6xzuk2/doomfists_new_hitbox_analysis_xpost_from/dmo8j8n/",
                childId: null,
                parentId: "dmjuw52"
                );

            Assert.IsNull(returned, "The returned value should have been null");
            logger.Verify();
        }
예제 #11
0
        public void PostUrlFromChildDetails_child_id_no_trailing_slash()
        {
            const string childUrl =
                "https://www.reddit.com/r/Competitiveoverwatch/comments/6xzuk2/doomfists_new_hitbox_analysis_xpost_from/dmo8j8n";
            const string childId  = "dmo8j8n";
            const string expected =
                "https://www.reddit.com/r/Competitiveoverwatch/comments/6xzuk2/doomfists_new_hitbox_analysis_xpost_from/";

            logger.Setup(x => x.Error(It.IsAny <string>(), null, null));
            ids = new Ids(logger.Object);
            var returned = ids.PostUrlFromChildDetails(childUrl, childId);

            Assert.AreEqual(expected, returned, $"Expected {expected} but got {returned}");
            logger.Verify();
        }
예제 #12
0
        public void ParentUrlFromChildDetails_expected_success()
        {
            ids = new Ids(logger.Object);
            const string parentUrl =
                "https://www.reddit.com/r/Competitiveoverwatch/comments/6xzuk2/doomfists_new_hitbox_analysis_xpost_from/dmjuw52/";
            var returned = ids.ParentUrlFromChildDetails(
                childUrl:
                "https://www.reddit.com/r/Competitiveoverwatch/comments/6xzuk2/doomfists_new_hitbox_analysis_xpost_from/dmo8j8n/",
                childId: "dmo8j8n",
                parentId: "dmjuw52"
                );

            Assert.AreEqual(parentUrl, returned, $"The generated URL {parentUrl} did not match {returned}");
            logger.Verify();
        }
예제 #13
0
        public void ParentUrlFromChildDetails_unexpected_url()
        {
            const string childId  = "dmo8j8n";
            const string parentId = "dmjuw52";
            const string childUrl =
                "https://www.reddit.com/r/Competitiveoverwatch/comments/6xzuk2/doomfists_new_hitbox_analysis_xpost_from/";

            logger.Setup(x => x.Error(It.IsAny <string>(), null, null));
            ids = new Ids(logger.Object);
            var returned = ids.ParentUrlFromChildDetails(
                childUrl: childUrl,
                childId: childId,
                parentId: parentId
                );

            Assert.IsNull(returned, $"Somehow an ID was generated: {returned}");
        }
예제 #14
0
        public void SubredditIdFromUrl_url_is_empty()
        {
            var url = string.Empty;

            logger.Setup(x => x.Info(It.IsAny <string>(), It.IsAny <string>()));

            ids = new Ids(logger.Object);
            var result = ids.ExtractSubredditIdFromUrl(url);

            Assert.IsNull(result);

            logger.Verify(
                x => x.Info(
                    It.Is <string>(message => message == "URL is null or empty.  No subreddit ID found."),
                    It.IsAny <string>()
                    ),
                Times.Once
                );
        }
예제 #15
0
        public void SubredditIdFromUrl_url_is_not_reddit()
        {
            const string url =
                "https://www.example.com/stuff";

            logger.Setup(x => x.Info(It.IsAny <string>(), It.IsAny <string>()));

            ids = new Ids(logger.Object);
            var result = ids.ExtractSubredditIdFromUrl(url);

            Assert.IsNull(result);

            logger.Verify(
                x => x.Info(
                    It.Is <string>(message => message == $"No subreddit found in URL {url}"),
                    It.IsAny <string>()
                    ),
                Times.Once
                );
        }
예제 #16
0
 public NetxFodyInstance(ILog log, IIds idsManager) : base(log, idsManager)
 {
 }
 public ThreadResponsePostTransformer(IIds ids)
 {
     this.ids = ids;
 }
예제 #18
0
 public NetxAsync(ILog log, IIds idsManager) : base(log, idsManager)
 {
 }
 public ThreadResponseCommentTransformer(IIds ids, ILog log)
 {
     this.ids = ids;
     this.log = log;
 }
예제 #20
0
파일: NetxBase.cs 프로젝트: luyikk/NetX
 public NetxBase(ILog log, IIds idsManager)
 {
     Log        = log;
     IdsManager = idsManager;
 }