public async Task TestRunOneUserValidToken() { string testResultPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ApiResults", "GetTokenSuccessResult.json"); string json = File.ReadAllText(testResultPath); JObject jObject = JObject.Parse(json); jObject["access_token"] = await Utils.GetTestToken(); json = JsonConvert.SerializeObject(jObject); var mocks = Utils.CreateDefaultGraphApiMock(json); await Utils.SetDefaultValueDbContextAsync(); services.AddScoped(service => mocks.Item2); ServiceProvider serviceProvider = services.BuildServiceProvider(); ApiCallManager apiCallManager = serviceProvider.GetRequiredService <ApiCallManager>(); (long, string)result = await apiCallManager.RunAsync(123456789, true); string[] message = result.Item2.Split('\n'); Assert.AreEqual(2, message.Length); result = await apiCallManager.RunAsync(987654321, true); message = result.Item2.Split('\n'); Assert.AreEqual(1, message.Length); }
public async Task TestRunAllAsync() { string testResultPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ApiResults", "GetTokenFailedResult.json"); string json = File.ReadAllText(testResultPath); var mocks = Utils.CreateDefaultGraphApiMock(json); await Utils.SetDefaultValueDbContextAsync(); services.AddScoped(service => mocks.Item2); ServiceProvider serviceProvider = services.BuildServiceProvider(); ApiCallManager apiCallManager = serviceProvider.GetRequiredService <ApiCallManager>(); await apiCallManager.RunAsync(); }
public async Task TestRunOneUserInvalidToken() { string testResultPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ApiResults", "GetTokenFailedResult.json"); string json = File.ReadAllText(testResultPath); var mocks = Utils.CreateDefaultGraphApiMock(json); await Utils.SetDefaultValueDbContextAsync(); services.AddScoped(service => mocks.Item2); ServiceProvider serviceProvider = services.BuildServiceProvider(); ApiCallManager apiCallManager = serviceProvider.GetRequiredService <ApiCallManager>(); (long, string)result = await apiCallManager.RunAsync(123456789); string[] message = result.Item2.Split('\n'); Assert.AreEqual(1, message.Length); }