public void GetSingleOrDefault_Poco_WithCql() { // Get a user that exists var user = CqlClient.SingleOrDefault <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 = CqlClient.SingleOrDefault <PlainUser>("SELECT * FROM users WHERE userid = ?", Guid.Empty); notExistingUser.Should().BeNull(); }
public void GetSingleOrDefault_OneColumnFlattened_WithCql() { // Get the lucky numbers for a user that exists var luckyNumbers = CqlClient.SingleOrDefault <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 = CqlClient.SingleOrDefault <bool?>("SELECT isactive FROM users WHERE userid = ?", Guid.Empty); isActive.Should().NotHaveValue(); }
public void Delete_Poco_WithCql() { // Pick an existing user from the DB and verify they currently exist (sanity check) Guid userId = TestDataHelper.Users[5].UserId; var userToDelete = CqlClient.Single <UserWithPrimaryKeyDecoration>("WHERE userid = ?", userId); userToDelete.Should().NotBeNull(); // Delete using CQL string (no POCO passed here, just CQL + params) CqlClient.Delete <UserWithPrimaryKeyDecoration>("WHERE userid = ?", userId); // Verify user is actually deleted var foundUser = CqlClient.SingleOrDefault <UserWithPrimaryKeyDecoration>("WHERE userid = ?", userId); foundUser.Should().BeNull(); }
public void Delete_Poco() { // Get an existing user from the DB Guid userId = TestDataHelper.Users[1].UserId; var userToDelete = CqlClient.Single <UserWithPrimaryKeyDecoration>("WHERE userid = ?", userId); userToDelete.Should().NotBeNull(); // Delete CqlClient.Delete(userToDelete); // Verify user is gone var foundUser = CqlClient.SingleOrDefault <UserWithPrimaryKeyDecoration>("WHERE userid = ?", userId); foundUser.Should().BeNull(); }