public void Execute() { Task <bool> .Factory.StartNew(() => packageManagerClient.GetTermsOfUseAcceptanceStatus()). ContinueWith(t => { // The above GetTermsOfUseAcceptanceStatus call will get the // user to sign-in. If the user cancels that sign-in dialog // without signing in, we won't show the terms of use dialog, // simply return from here. // if (authenticationManager.LoginState != LoginState.LoggedIn) { return; } var termsOfUseAccepted = t.Result; if (termsOfUseAccepted) { // Terms of use accepted, proceed to publish. callbackAction.Invoke(); } else { // Prompt user to accept the terms of use. ShowTermsOfUseForPublishing(); } }, TaskScheduler.FromCurrentSynchronizationContext()); }
public void GetTermsOfUseAcceptanceStatus_ReturnsFalseWhenRequestThrowsAnException() { 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.GetTermsOfUseAcceptanceStatus(); Assert.IsFalse(res); }
public void GetTermsOfUseAcceptanceStatus_ReturnsFalseWhenNotAccepted() { var resp = new ResponseWithContentBody <TermsOfUseStatus>() { content = new TermsOfUseStatus() { accepted = false } }; 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.GetTermsOfUseAcceptanceStatus(); Assert.IsFalse(res); }
internal void Execute(bool preventReentrant) { if (preventReentrant && Interlocked.Increment(ref lockCount) > 1) { // Determine if there is already a previous request to display // terms of use dialog, if so, do nothing for the second time. Interlocked.Decrement(ref lockCount); return; } Task <bool> .Factory.StartNew(() => packageManagerClient.GetTermsOfUseAcceptanceStatus()). ContinueWith(t => { // The above GetTermsOfUseAcceptanceStatus call will get the // user to sign-in. If the user cancels that sign-in dialog // without signing in, we won't show the terms of use dialog, // simply return from here. // if (authenticationManager.LoginState != LoginState.LoggedIn) { return; } var termsOfUseAccepted = t.Result; if (termsOfUseAccepted) { // Terms of use accepted, proceed to publish. callbackAction.Invoke(); } else { // Prompt user to accept the terms of use. ShowTermsOfUseForPublishing(); } }, TaskScheduler.FromCurrentSynchronizationContext()). ContinueWith(t => { // Done with terms of use dialog, decrement counter. Interlocked.Decrement(ref lockCount); }, TaskScheduler.FromCurrentSynchronizationContext()); }
public void GetTermsOfUseAcceptanceStatus_ReturnsFalseWhenRequestThrowsAnException() { 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.GetTermsOfUseAcceptanceStatus(); Assert.IsFalse(res); }
public void GetTermsOfUseAcceptanceStatus_ReturnsFalseWhenNotAccepted() { var resp = new ResponseWithContentBody<TermsOfUseStatus>() { content = new TermsOfUseStatus() { accepted = false } }; 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.GetTermsOfUseAcceptanceStatus(); Assert.IsFalse(res); }