/// <summary> /// Initialize the Application. /// </summary> /// <param name="loggingContext">The logging context.</param> /// <returns>The task.</returns> public async Task InitializeApplicationAsync(LoggingContext loggingContext) { if (Application == null) { IApplications ApplicationsResource = null; if (!(ClientPlatform as ClientPlatform).IsSandBoxEnv) { Uri discoverUri = ClientPlatform.DiscoverUri; Uri baseUri = UriHelper.GetBaseUriFromAbsoluteUri(discoverUri.ToString()); var discover = new Discover(m_restfulClient, baseUri, discoverUri, this); await discover.RefreshAndInitializeAsync(loggingContext, ApplicationEndpointId.ToString()).ConfigureAwait(false); ApplicationsResource = discover.Applications; } else { Uri applicationsUri = Constants.PlatformApplicationsUri_SandBox; Uri baseUri = UriHelper.GetBaseUriFromAbsoluteUri(applicationsUri.ToString()); if (this.ApplicationEndpointId != null) { applicationsUri = UriHelper.AppendQueryParameterOnUrl(applicationsUri.ToString(), Constants.EndpointId, ApplicationEndpointId.ToString(), false); } ApplicationsResource = new Applications(m_restfulClient, null, baseUri, applicationsUri, this); } await ApplicationsResource.RefreshAndInitializeAsync(loggingContext).ConfigureAwait(false); Application = ApplicationsResource.Application; await Application.RefreshAndInitializeAsync(loggingContext).ConfigureAwait(false); } }
public void TestSetup() { var baseUri = new Uri("https://example.com/"); var resourceUri = new Uri("https://example.com/invitation/1"); var restfulClient = new MockRestfulClient(); var parent = new object(); Logger.RegisterLogger(new ConsoleLogger()); var applicationsResource = new ApplicationsResource(resourceUri.ToString()); m_applicationResource = new ApplicationResource(resourceUri.ToString()); var communicationResource = new CommunicationResource(resourceUri.ToString()); var conversationResource = new ConversationResource(resourceUri.ToString()); var invitationResource = new InvitationResource(resourceUri.ToString()) { Application = m_applicationResource }; var applications = new Applications(restfulClient, applicationsResource, baseUri, resourceUri, parent); var application = new Application(restfulClient, m_applicationResource, baseUri, resourceUri, applications); var communication = new Communication(restfulClient, communicationResource, baseUri, resourceUri, application); m_conversation = new Conversation(restfulClient, conversationResource, baseUri, resourceUri, communication); var mockInvitation = new Mock <Invitation <InvitationResource, TestCapabilities> >(restfulClient, invitationResource, baseUri, resourceUri, communication); mockInvitation.CallBase = true; m_invitation = mockInvitation.Object; // Resource deserealization understands only those resources which are registered. This means we cannot use mock // implementation of InvitationResource to raise any event. Raise an event for MessagingCall instead. EventsEntity eventsEntity = TestHelper.GetEventsEntityForEventsInFile("Event_MessagingInvitationCompleted.json"); m_eventContext = new EventContext() { BaseUri = baseUri, EventFullHref = resourceUri, EventEntity = eventsEntity.Senders[0].Events[0] }; }
/// <summary>Constructs a new service.</summary> /// <param name="initializer">The service initializer.</param> public DataTransferService(Google.Apis.Services.BaseClientService.Initializer initializer) : base(initializer) { applications = new ApplicationsResource(this); transfers = new TransfersResource(this); }