Ejemplo n.º 1
0
        public async Task ThrowGraphServiceException()
        {
            //TestCommon.Instance.Mocking = false;
            using (var context = await TestCommon.Instance.GetContextAsync(TestCommon.TestSite))
            {
                bool microsoftGraphServiceExceptionThrown = false;
                MicrosoftGraphError error = null;
                try
                {
                    // try adding a channel while the Team was not yet loaded, should result in not correctly formatted query sent to graph
                    await context.Team.Channels.AddAsync("Fail channel");
                }
                catch (ServiceException ex)
                {
                    if (ex is MicrosoftGraphServiceException)
                    {
                        error = ex.Error as MicrosoftGraphError;
                        microsoftGraphServiceExceptionThrown = true;
                    }
                }

                Assert.IsTrue(microsoftGraphServiceExceptionThrown);
                Assert.IsTrue(!string.IsNullOrEmpty(error.Code));
                Assert.IsTrue(!string.IsNullOrEmpty(error.Message));
                Assert.IsTrue(error.Type == ErrorType.GraphServiceError);
            }
        }
Ejemplo n.º 2
0
        public async Task ThrowGraphServiceException()
        {
            //TestCommon.Instance.Mocking = false;
            using (var context = await TestCommon.Instance.GetContextAsync(TestCommon.TestSite))
            {
                bool microsoftGraphServiceExceptionThrown = false;
                MicrosoftGraphError error = null;
                try
                {
                    // Send a wrong Graph query to trigger a graph exception
                    await(context.Team as Team).RawRequestAsync(new ApiCall("sites/bla", ApiType.Graph), HttpMethod.Get);
                }
                catch (ServiceException ex)
                {
                    if (ex is MicrosoftGraphServiceException)
                    {
                        error = ex.Error as MicrosoftGraphError;
                        microsoftGraphServiceExceptionThrown = true;
                    }
                }

                Assert.IsTrue(microsoftGraphServiceExceptionThrown);
                Assert.IsTrue(!string.IsNullOrEmpty(error.Code));
                Assert.IsTrue(!string.IsNullOrEmpty(error.Message));
                Assert.IsTrue(error.Type == ErrorType.GraphServiceError);
            }
        }
Ejemplo n.º 3
0
        public void GraphErrorDeserialization()
        {
            bool microsoftGraphServiceExceptionThrown = false;
            MicrosoftGraphError error = null;

            try
            {
                throw new MicrosoftGraphServiceException(ErrorType.GraphServiceError, 400, sampleGraphError);
            }
            catch (ServiceException ex)
            {
                if (ex is MicrosoftGraphServiceException)
                {
                    error = ex.Error as MicrosoftGraphError;
                    microsoftGraphServiceExceptionThrown = true;
                }
            }

            Assert.IsTrue(microsoftGraphServiceExceptionThrown);
            Assert.IsTrue(!string.IsNullOrEmpty(error.Code));
            Assert.IsTrue(!string.IsNullOrEmpty(error.Message));
            Assert.IsTrue(error.Type == ErrorType.GraphServiceError);
        }