Пример #1
0
        public async void GetFirstOrDefaultAsync_Poco_WithCql()
        {
            // Get random first or default user and verify they are same as user from test data
            var user = await CqlClient.FirstOrDefaultAsync <PlainUser>("SELECT * FROM users");

            user.ShouldBeEquivalentTo(TestDataHelper.Users.Single(u => u.UserId == user.UserId), opt => opt.AccountForTimestampAccuracy());

            // Get first or default where user id doesn't exist and make sure we get null
            var notExistingUser = await CqlClient.FirstOrDefaultAsync <PlainUser>("SELECT * FROM users WHERE userid = ?", Guid.Empty);

            notExistingUser.Should().BeNull();
        }
Пример #2
0
        public async void GetFirstOrDefaultAsync_OneColumnFlattened_WithCql()
        {
            // Get random first or default name and make sure it was one from our test data
            var name = await CqlClient.FirstOrDefaultAsync <string>("SELECT name FROM users");

            TestDataHelper.Users.Select(u => u.Name).Should().Contain(name);

            // Get random first or default login history for user that does not exist and make sure we get null
            var loginHistory = await CqlClient.FirstOrDefaultAsync <List <DateTimeOffset> >("SELECT loginhistory FROM users WHERE userid = ?", Guid.Empty);

            loginHistory.Should().BeNull();
        }