public void UserAdded_AppearsInContext() { SourceUser newUser; var srcUser = new SourceUser { EmailAddress = "*****@*****.**", UserName = "******" }; using (var efContext = new SourceDbContext(_srcConnection)) { efContext.Users.Add(srcUser); efContext.SaveChanges(); } using (var source = new EfDataContext <SourceDbContext>(new SourceDbContext(_srcConnection)) as IDataSource) { newUser = source.Entities <SourceUser>().Single(x => x.EmailAddress == srcUser.EmailAddress); } Assert.Multiple(() => { Assert.That(newUser.Id, Is.EqualTo(srcUser.Id)); Assert.That(newUser.EmailAddress, Is.EqualTo(srcUser.EmailAddress)); }); }
public override string ToString(FormatType format, object supplement = null) { return(format switch { FormatType.Brief => $"{AliasID}.{Alias}——{CorrespondingSong?.SongTitle}", FormatType.Detail => $"{AliasID}.{Alias}——{CorrespondingSong?.SongTitle}" + $"{SourceUser?.Be($"\n贡献者:{SourceUser.Name}")}", FormatType.Customize1 => $"{Alias}", _ => throw new ArgumentOutOfRangeException(nameof(format), format, null) });
public override string ToString(FormatType formatType, object supplement = null) { return(formatType switch { FormatType.Brief => $"{ID}.{Reply}", FormatType.Detail => $"{ID}.{Reply}" + SourceUser?.Be($"\n贡献人:{SourceUser.Name}"), _ => throw new ArgumentOutOfRangeException(nameof(formatType), formatType, null) });
public override string ToString(FormatType formatType, object supplement = null) { return(formatType switch { FormatType.Brief => $"{ID}.{(IsOminous ? "忌" : "宜")}{Title}:{Content}", FormatType.Detail => $"{ID}.{(IsOminous ? "忌" : "宜")}{Title}\n{Content}" + SourceUser?.Be($"\n贡献人:{SourceUser.Name}"), FormatType.Customize1 => $"{(IsOminous ? "忌" : "宜")}{Title}:{Content}", _ => throw new ArgumentOutOfRangeException(nameof(formatType), formatType, null) });
public static User LoadBySourceUser(SourceUser sourceUser, MySqlConnection conn) { var da = new MySqlDataAdapter( $"SELECT id, hash_key, src_domain, src_user_id, login, created_at FROM users WHERE src_domain='{sourceUser.Domain}' and src_user_id='{sourceUser.Id}'", conn); var ds = new DataSet("users"); da.Fill(ds); if (ds.Tables[0].Rows.Count == 1) { return(new User(ds.Tables[0].Rows[0])); } return(null); }