public async void GetSingleOrDefaultAsync_Poco_WithCql() { // Get a user that exists var user = await CqlClient.SingleOrDefaultAsync <PlainUser>("SELECT * FROM users WHERE userid = ?", TestDataHelper.Users[1].UserId); user.ShouldBeEquivalentTo(TestDataHelper.Users[1], opt => opt.AccountForTimestampAccuracy()); // Get a user that doesn't exist (using Guid.Empty as the Id) var notExistingUser = await CqlClient.SingleOrDefaultAsync <PlainUser>("SELECT * FROM users WHERE userid = ?", Guid.Empty); notExistingUser.Should().BeNull(); }
public async void GetSingleOrDefaultAsync_OneColumnFlattened_WithCql() { // Get the lucky numbers for a user that exists var luckyNumbers = await CqlClient.SingleOrDefaultAsync <HashSet <int> >("SELECT luckynumbers FROM users WHERE userid = ?", TestDataHelper.Users[1].UserId); luckyNumbers.Should().BeEquivalentTo(TestDataHelper.Users[1].LuckyNumbers); // Get IsActive for a user that doesn't exist var isActive = await CqlClient.SingleOrDefaultAsync <bool?>("SELECT isactive FROM users WHERE userid = ?", Guid.Empty); isActive.Should().NotHaveValue(); }
public async void DeleteAsync_Poco_WithCql() { // Pick an existing user from the DB and verify they currently exist (sanity check) Guid userId = TestDataHelper.Users[4].UserId; var userToDelete = await CqlClient.SingleAsync <UserWithPrimaryKeyDecoration>("WHERE userid = ?", userId); userToDelete.Should().NotBeNull(); // Delete using CQL string (no POCO passed here, just CQL + params) await CqlClient.DeleteAsync <UserWithPrimaryKeyDecoration>("WHERE userid = ?", userId); // Verify user is actually deleted var foundUser = await CqlClient.SingleOrDefaultAsync <UserWithPrimaryKeyDecoration>("WHERE userid = ?", userId); foundUser.Should().BeNull(); }
public async void DeleteAsync_Poco() { // Get an existing user from the DB Guid userId = TestDataHelper.Users[0].UserId; var userToDelete = await CqlClient.SingleAsync <UserWithPrimaryKeyDecoration>("WHERE userid = ?", userId); userToDelete.Should().NotBeNull(); // Delete await CqlClient.DeleteAsync(userToDelete); // Verify user is gone var foundUser = await CqlClient.SingleOrDefaultAsync <UserWithPrimaryKeyDecoration>("WHERE userid = ?", userId); foundUser.Should().BeNull(); }