private static async Task <long> GetFirstUnitId(TcClient client) { var units = await client.Units.OnlyOccuped().GetAll(CancellationToken.None, 1); var firstUnitId = units.Slice(0, 1).ToArray()[0].Id; return(firstUnitId); }
private static async Task <long> GetFirstTenantId(TcClient client) { var tenants = await client.Tenants.OnlyMovedIn().GetAll(CancellationToken.None, 1); var firstTenantId = tenants.Slice(0, 1).ToArray()[0].Id; return(firstTenantId); }
public async Task When_GetUnits() { var client = new TcClient(_context); var sut = client.Units; var all = await sut.GetAll(CancellationToken.None); all.Should().NotBeNull(); all.Length.Should().NotBe(0); all.AsEnumerable().Select(x => x.Id).Should().OnlyHaveUniqueItems(); }
public async Task When_GettingUserInfo() { var sut = new TcClient(_context); var userInfo = await sut.GetUserInfo(CancellationToken.None); using var _ = new AssertionScope(); userInfo.Should().NotBeNull(); userInfo.FirstName.Should().NotBeNullOrWhiteSpace(); userInfo.LastName.Should().NotBeNullOrWhiteSpace(); userInfo.Id.Should().NotBe(0); }
public TeamCityClientTests() { var fileInfo = new FileInfo("../../appsettings.txt"); if (!fileInfo.Exists) { throw new FileNotFoundException("Missing appsettings file that provides TeamCity credentials"); } Settings = new TextFileSettings("../../appsettings.txt"); Client = new TcClient( Settings.GetString("ServerApiBaseUrl"), Settings.GetString("UserName"), Settings.GetString("Password")); }
public async Task When_GettingMNoLeaseTenants() { var client = new TcClient(_context); var sut = client.Tenants.OnlyNoLease(); var all = await sut.GetAll(CancellationToken.None); using var _ = new AssertionScope(); all.Should().NotBeNull(); // Won't check for zero on this one, since it's normal for it to be zero all.AsEnumerable().Select(x => x.Id).Should().OnlyHaveUniqueItems(); }
public async Task When_GettingMovedInTenants() { var client = new TcClient(_context); var sut = client.Tenants.OnlyMovedIn(); var all = await sut.GetAll(CancellationToken.None); using var _ = new AssertionScope(); all.Should().NotBeNull(); all.Length.Should().NotBe(0); all.AsEnumerable().Select(x => x.Id).Should().OnlyHaveUniqueItems(); }
public async Task When_GetExpenseTransactions() { var client = new TcClient(_context); var sut = client.Transactions .ForCategory(TcTransactionCategory.Expense); var all = await sut.GetAll(CancellationToken.None); all.Should().NotBeNull(); all.Length.Should().NotBe(0); all.AsEnumerable().Select(x => x.Id).Should().OnlyHaveUniqueItems(); Console.WriteLine($"There is {all.Length} expense transactions."); }
public async Task When_GetTransactionsForUnit() { var client = new TcClient(_context); var firstUnitId = await GetFirstUnitId(client); var sut = client.Transactions .ForCategory(TcTransactionCategory.Income) .ForUnit(firstUnitId); var all = await sut.GetAll(CancellationToken.None); all.Should().NotBeNull(); //all.Length.Should().NotBe(0); all.AsEnumerable().Select(x => x.Id).Should().OnlyHaveUniqueItems(); Console.WriteLine($"There is {all.Length} income transactions for unit {firstUnitId}."); }
public async Task When_GetBalancePerProperty() { var client = new TcClient(_context); var all = (await client.Transactions .ForCategory(TcTransactionCategory.Income) .ForStatus(TcTransactionStatus.WithBalance) .GetAll(CancellationToken.None)) .AsEnumerable() .Where(t => t.PropertyId != null) // only property-specific income .GroupBy(t => (long)t.PropertyId, t => t.Balance) // group them .Select(g => (propertyId: g.Key, balance: g.Sum())) // summarize .ToArray(); // create final array all.Should().NotBeNull(); all.Length.Should().NotBe(0); all.AsEnumerable().Select(x => x.propertyId).Should().OnlyHaveUniqueItems(); }