public async Task Insert_row() { var expected = new User() { FirstName = "Arne", Id = Guid.NewGuid() }; await _connection.InsertAsync(expected); var actual = await _connection.FirstAsync<User>(new { expected.Id }); actual.FirstName.Should().Be(expected.FirstName); actual.Id.Should().Be(expected.Id); }
public void Insert_row() { var expected = new User() { FirstName = "Arne", Id = Guid.NewGuid() }; _connection.Insert(expected); var actual = _connection.First<User>(new { expected.Id }); actual.FirstName.Should().Be(expected.FirstName); actual.Id.Should().Be(expected.Id); }
public void Insert(SQLiteConnection connection, int numberOfUsers) { var r = new Random(); for (var i = 0; i < numberOfUsers; i++) { var user = new User { FirstName = "First" + i, LastName = Guid.NewGuid().ToString(), Id = Guid.NewGuid(), DateOfBirth = DateTime.Today.AddDays(r.Next(-100, 100)), MessageCount = i + 10 }; Users.Add(user); connection.Insert(user); } }
public AsyncCommandExtensionsTests() { CommandBuilderFactory.Assign(mapper => new SqliteCommandBuilder(mapper)); _dbFile = Path.GetTempFileName(); string cs = "URI=file:" + _dbFile; _connection = new SQLiteConnection(cs); _connection.Open(); using (var cmd = _connection.CreateCommand()) { cmd.CommandText = "CREATE TABLE Users (Id varchar(20) not null primary key, FirstName varchar(20), LastName varchar(20), DateOfBirth NUMERIC, MessageCount integer)"; cmd.ExecuteNonQuery(); } _dob = DateTime.Now; _dob=_dob.AddSeconds(0 - _dob.Second); using (var cmd = _connection.CreateCommand()) { for (int i = 0; i < 50; i++) { var user = new User { FirstName = "First" + i, LastName = Guid.NewGuid().ToString(), Id = Guid.NewGuid(), DateOfBirth = _dob, MessageCount = i + 10 }; _users.Add(user); cmd.Insert(user); } } }