Exemplo n.º 1
0
        public void GetProfileTest1()
        {
            Global.TOKEN = "";
            Exception    exception = null;
            var          container = UnityContainerSuppor.BuildUnityContainer();
            var          instance  = container.Resolve <InstagramBussinessImpl>();
            EndpointImpl endpoint  = new EndpointImpl(instance);
            Profile      profile   = null;

            Task.Run(async() =>
            {
                try
                {
                    profile = await endpoint.GetProfile();
                }
                catch (Exception ex)
                {
                    exception = ex;
                }
            }).GetAwaiter().GetResult();

            Assert.IsNull(profile);
            Assert.IsNotNull(exception);
            Assert.AreEqual(exception.Message, "Missing client_id or access_token URL parameter.");
        }
Exemplo n.º 2
0
 public void Should_throw_exception_if_status_is_not_200_OK()
 {
     var responseXml = "<someXml/>";
     var url = "http://some.uri.com/page.xml";
     _httpGet.Expect(x => x.Request(url));
     _httpGet.Expect(x => x.StatusCode).Return(404);
     _httpGet.Expect(x => x.ResponseBody).Return(responseXml);
     var endpoint = new EndpointImpl(_httpGet, url);
     var ex = Assert.Throws<HttpException>(() => endpoint.GetXml());
     Assert.That(ex.Message, Is.EqualTo("Http status code is 404"));
 }
Exemplo n.º 3
0
 public void Should_get_cctray_item_success()
 {
     var responseXml = "<someXml/>";
     var url = "http://some.uri.com/page.xml";
     _httpGet.Expect(x => x.Request(url));
     _httpGet.Expect(x => x.StatusCode).Return(200);
     _httpGet.Expect(x => x.ResponseBody).Return(responseXml);
     var endpoint = new EndpointImpl(_httpGet, url);
     var xml = endpoint.GetXml();
     Assert.That(xml, Is.EqualTo(responseXml));
 }
Exemplo n.º 4
0
        public void PostCommentTest1()
        {
            Global.TOKEN = "39217616.abb738d.964d271718624e29a213d5b8d602ccf7";
            var          container = UnityContainerSuppor.BuildUnityContainer();
            var          instance  = container.Resolve <InstagramBussinessImpl>();
            EndpointImpl endpoint  = new EndpointImpl(instance);
            bool         test      = false;

            Task.Run(async() =>
            {
                test = await endpoint.PostComment("#a #b #c #d #e", "1593619934200949826_5964438851");
            }).Wait();
            Assert.IsFalse(test);
        }
Exemplo n.º 5
0
        public void GetImageRecentPublishByUserTest()
        {
            Global.TOKEN = "39217616.abb738d.964d271718624e29a213d5b8d602ccf7";
            var          container = UnityContainerSuppor.BuildUnityContainer();
            var          instance  = container.Resolve <InstagramBussinessImpl>();
            EndpointImpl endpoint  = new EndpointImpl(instance);
            Picture      picture   = null;

            Task.Run(async() =>
            {
                picture = await endpoint.GetImageRecentPublishByUser("5964438851");
            }).GetAwaiter().GetResult();
            Assert.IsNotNull(picture);
        }
Exemplo n.º 6
0
        public void SearchUserTest()
        {
            Global.TOKEN = "39217616.abb738d.964d271718624e29a213d5b8d602ccf7";
            var            container   = UnityContainerSuppor.BuildUnityContainer();
            var            instance    = container.Resolve <InstagramBussinessImpl>();
            EndpointImpl   endpoint    = new EndpointImpl(instance);
            List <Profile> listProfile = null;

            Task.Run(async() =>
            {
                listProfile = await endpoint.SearchUser("anh");
            }).GetAwaiter().GetResult();

            Assert.IsTrue(listProfile.Count > 0);
        }
Exemplo n.º 7
0
        public void LikeImageTest1()
        {
            Global.TOKEN = "39217616.abb738d.964d271718624e29a213d5b8d602ccf7";
            var          container   = UnityContainerSuppor.BuildUnityContainer();
            var          instance    = container.Resolve <InstagramBussinessImpl>();
            EndpointImpl endpoint    = new EndpointImpl(instance);
            bool         testSuccess = false;

            Task.Run(async() =>
            {
                testSuccess = await endpoint.LikeImage("");
            }).Wait();

            Assert.IsFalse(testSuccess);
        }
Exemplo n.º 8
0
        public void LoadCommentsTest()
        {
            Global.TOKEN = "39217616.abb738d.964d271718624e29a213d5b8d602ccf7";
            var            container   = UnityContainerSuppor.BuildUnityContainer();
            var            instance    = container.Resolve <InstagramBussinessImpl>();
            EndpointImpl   endpoint    = new EndpointImpl(instance);
            List <Comment> listComment = new List <Comment>();

            Task.Run(async() =>
            {
                listComment = await endpoint.LoadComments("1593619934200949826_5964438851");
            }).Wait();


            Assert.IsTrue(listComment.Count > 0);
        }
Exemplo n.º 9
0
        public void GetProfileTest()
        {
            Global.TOKEN = "39217616.abb738d.964d271718624e29a213d5b8d602ccf7";
            var          container = UnityContainerSuppor.BuildUnityContainer();
            var          instance  = container.Resolve <InstagramBussinessImpl>();
            EndpointImpl endpoint  = new EndpointImpl(instance);
            Profile      profile   = null;

            Task.Run(async() =>
            {
                profile = await endpoint.GetProfile();
            }).GetAwaiter().GetResult();

            Assert.IsNotNull(profile);
            Assert.AreEqual(profile.full_name, "Anh Nguyen");
        }
Exemplo n.º 10
0
        public void LoadCommentsTest1()
        {
            Global.TOKEN = "5964438851.abb738d.8d2695e0f6624fc9ab2c37dd02f841cd";
            var            container   = UnityContainerSuppor.BuildUnityContainer();
            var            instance    = container.Resolve <InstagramBussinessImpl>();
            EndpointImpl   endpoint    = new EndpointImpl(instance);
            List <Comment> listComment = new List <Comment>();
            Exception      exception   = null;

            Task.Run(async() =>
            {
                try
                {
                    listComment = await endpoint.LoadComments("");
                }catch (Exception ex)
                {
                    exception = ex;
                }
            }).Wait();


            Assert.IsNotNull(exception);
        }
Exemplo n.º 11
0
        public void GetImageRecentPublishByUserTest1()
        {
            Global.TOKEN = "";
            var          container = UnityContainerSuppor.BuildUnityContainer();
            var          instance  = container.Resolve <InstagramBussinessImpl>();
            EndpointImpl endpoint  = new EndpointImpl(instance);
            Picture      picture   = null;
            Exception    exception = null;

            Task.Run(async() =>
            {
                try
                {
                    picture = await endpoint.GetImageRecentPublishByUser("5964438851");
                }
                catch (Exception ex)
                {
                    exception = ex;
                }
            }).GetAwaiter().GetResult();
            Assert.IsNull(picture);
            Assert.IsNotNull(exception);
        }
Exemplo n.º 12
0
        public void SearchUserTest1()
        {
            Global.TOKEN = "";
            var            container   = UnityContainerSuppor.BuildUnityContainer();
            var            instance    = container.Resolve <InstagramBussinessImpl>();
            EndpointImpl   endpoint    = new EndpointImpl(instance);
            Exception      exception   = null;
            List <Profile> listProfile = null;

            Task.Run(async() =>
            {
                try
                {
                    listProfile = await endpoint.SearchUser("anh");
                }
                catch (Exception ex)
                {
                    exception = ex;
                }
            }).GetAwaiter().GetResult();

            Assert.IsNull(listProfile);
            Assert.IsNotNull(exception);
        }