Example #1
0
        public async Task TestGetTokenAzureAppNotFoundAsync()
        {
            string       testResultPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ApiResults", "GetTokenSuccessResult.json");
            string       json           = File.ReadAllText(testResultPath);
            Guid         clientId       = Guid.NewGuid();
            var          mocks          = Utils.CreateDefaultGraphApiMock(json);
            BotDbContext db             = Utils.CreateMemoryDbContext();

            DefaultGraphApi defaultGraphApi = new DefaultGraphApi(db, mocks.Item1, mocks.Item2);

            (string, string)_ = await defaultGraphApi.GetTokenAsync(clientId, string.Empty);
        }
Example #2
0
        public async Task TestGetTokenSuccessAsync()
        {
            string testResultPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ApiResults", "GetTokenSuccessResult.json");
            string json           = File.ReadAllText(testResultPath);
            Guid   clientId       = Guid.NewGuid();
            var    mocks          = Utils.CreateDefaultGraphApiMock(json);
            await Utils.SetOneValueDbContextAsync(clientId);

            BotDbContext db = Utils.CreateMemoryDbContext();

            DefaultGraphApi defaultGraphApi = new DefaultGraphApi(db, mocks.Item1, mocks.Item2);

            (string, string)tokens = await defaultGraphApi.GetTokenAsync(clientId, string.Empty);

            JObject jObject = JObject.Parse(json);

            Assert.AreEqual(jObject["access_token"].ToString(), tokens.Item1);
            Assert.AreEqual(jObject["refresh_token"].ToString(), tokens.Item2);
        }