Ejemplo n.º 1
0
        private void ShowTermsOfUseForPublishing()
        {
            var additionalTerms = string.Empty;

            if (resourceProvider != null)
            {
                additionalTerms = resourceProvider.AdditionalPackagePublisherTermsOfUse;
            }

            if (!ShowTermsOfUseDialog(true, additionalTerms))
            {
                return; // Terms of use not accepted.
            }
            // If user accepts the terms of use, then update the record on
            // the server, before proceeding to show the publishing dialog.
            // This method is invoked on the UI thread, so when the server call
            // returns, invoke the publish dialog on the UI thread's context.
            //
            Task <bool> .Factory.StartNew(() => packageManagerClient.SetTermsOfUseAcceptanceStatus()).
            ContinueWith(t =>
            {
                if (t.Result)
                {
                    callbackAction.Invoke();
                }
            },
                         TaskScheduler.FromCurrentSynchronizationContext());
        }
        public void SetTermsOfUseAcceptanceStatus_ReturnsTrueWhenRequestThrowsAnException()
        {
            var gc = new Mock <IGregClient>();

            gc.Setup(x => x.ExecuteAndDeserializeWithContent <TermsOfUseStatus>(It.IsAny <TermsOfUse>())).Throws <Exception>();

            var pc = new PackageManagerClient(gc.Object, MockMaker.Empty <IPackageUploadBuilder>());

            var res = pc.SetTermsOfUseAcceptanceStatus();

            Assert.IsFalse(res);
        }
        public void SetTermsOfUseAcceptanceStatus_ReturnsTrueWhenRequestSucceeds()
        {
            var resp = new ResponseWithContentBody <TermsOfUseStatus>()
            {
                content = new TermsOfUseStatus()
                {
                    accepted = true
                }
            };

            var gc = new Mock <IGregClient>();

            gc.Setup(x => x.ExecuteAndDeserializeWithContent <TermsOfUseStatus>(It.IsAny <TermsOfUse>())).Returns(resp);

            var pc = new PackageManagerClient(gc.Object, MockMaker.Empty <IPackageUploadBuilder>());

            var res = pc.SetTermsOfUseAcceptanceStatus();

            Assert.IsTrue(res);
        }
        public void SetTermsOfUseAcceptanceStatus_ReturnsTrueWhenRequestThrowsAnException()
        {
            var gc = new Mock<IGregClient>();
            gc.Setup(x => x.ExecuteAndDeserializeWithContent<TermsOfUseStatus>(It.IsAny<TermsOfUse>())).Throws<Exception>();

            var pc = new PackageManagerClient(gc.Object, MockMaker.Empty<IPackageUploadBuilder>(), "");

            var res = pc.SetTermsOfUseAcceptanceStatus();

            Assert.IsFalse(res);
        }
        public void SetTermsOfUseAcceptanceStatus_ReturnsTrueWhenRequestSucceeds()
        {
            var resp = new ResponseWithContentBody<TermsOfUseStatus>()
            {
                content = new TermsOfUseStatus()
                {
                    accepted = true
                }
            };

            var gc = new Mock<IGregClient>();
            gc.Setup(x => x.ExecuteAndDeserializeWithContent<TermsOfUseStatus>(It.IsAny<TermsOfUse>())).Returns(resp);

            var pc = new PackageManagerClient(gc.Object, MockMaker.Empty<IPackageUploadBuilder>(), "");

            var res = pc.SetTermsOfUseAcceptanceStatus();

            Assert.IsTrue(res);
        }