public async Task InvokeWithNullBudgetsReturnsNull() { // Arrange var appSettings = new AppSettings { Splitwise = new Splitwise { ConsumerKey = "consumerKey", ConsumerSecret = "consumerSecret", FriendEmail = "friendEmail", TransactionsDatedAfter = new DateTimeOffset() }, Ynab = new Ynab { PersonalAccessToken = "personalAccessToken", BudgetName = "budgetName", SplitwiseAccountName = "splitwiseAccountName" } }; var ynabBudgets = new BudgetSummaryResponse(); _ynabClient.GetBudgets(true).Returns(ynabBudgets); // Act _sut = new GetYnabInfoOperation(_logger, _ynabClient); var result = await _sut.Invoke(appSettings); // Assert Assert.Null(result); }
public async Task InvokeWithValidSettingsReturnsExpected() { // Arrange var appSettings = new AppSettings { Splitwise = new Splitwise { ConsumerKey = "consumerKey", ConsumerSecret = "consumerSecret", FriendEmail = "friendEmail", TransactionsDatedAfter = new DateTimeOffset() }, Ynab = new Ynab { PersonalAccessToken = "personalAccessToken", BudgetName = "budgetName", SplitwiseAccountName = "splitwiseAccountName" } }; var ynabBudgetGuid = Guid.NewGuid(); var ynabBudgets = new BudgetSummaryResponse { Data = new BudgetModel { Budgets = new List <BudgetSummary> { new() { Name = "budgetName", Id = ynabBudgetGuid } } } }; _ynabClient.GetBudgets(true).Returns(ynabBudgets); var ynabBudgetAccountGuid = Guid.NewGuid(); var ynabBudgetAccounts = new AccountsResponse { Data = new AccountsModel { Accounts = new List <Account> { new() { Name = "splitwiseAccountName", Id = ynabBudgetAccountGuid } } } }; _ynabClient.GetBudgetAccounts(ynabBudgetGuid).Returns(ynabBudgetAccounts); var expected = new YnabInfo { Budget = new BudgetSummary { Name = "budgetName", Id = ynabBudgetGuid }, SplitwiseAccount = new Account { Name = "splitwiseAccountName", Id = ynabBudgetAccountGuid } }; // Act _sut = new GetYnabInfoOperation(_logger, _ynabClient); var result = await _sut.Invoke(appSettings); // Assert Assert.NotNull(result); Assert.Equal(expected, result); }