Exemplo n.º 1
0
 /// <summary>Initializes a new instance of the <see cref="GoogleCalendarConnector"/> class.</summary>
 public GoogleCalendarConnector(GoogleServiceAccountCredential accountCredential)
     : this(new Lazy <CalendarService>(
                () => new CalendarService(
                    InitByServiceAccount(
                        accountCredential.ApplicationName,
                        accountCredential.GetServiceAccountStream(),
                        Scopes))))
 {
 }
Exemplo n.º 2
0
 /// <summary>Initializes a new instance of the <see cref="HangoutsChatConnector"/> class.</summary>
 public HangoutsChatConnector(GoogleServiceAccountCredential accountCredential)
     : this(new Lazy <HangoutsChatService>(
                () => new HangoutsChatService(
                    InitByServiceAccount(
                        accountCredential.ApplicationName,
                        accountCredential.GetServiceAccountStream(),
                        Scopes))))
 {
 }
        public void GetServiceAccountStream_ShouldReturnTheStreamCached()
        {
            var text   = Encoding.ASCII.GetBytes("ABCD");
            var stream = new MemoryStream(text);

            _storageConnector.IsConnected.Returns(true);
            _storageConnector.GetFileStreamAsync("QZ/XY").Returns(stream);

            var result     = _accountCredential.GetServiceAccountStream();
            var resultText = Encoding.ASCII.GetString((result as MemoryStream).ToArray());
            var cacheText  = Encoding.ASCII.GetString(GoogleServiceAccountCredential.GoogleServiceAccount);

            Assert.AreEqual("ABCD", resultText);
            Assert.AreEqual("ABCD", cacheText);
        }