public async void Migrate() { var directTweetItem1 = new DirectTweet(); directTweetItem1.SetProperties("A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1, TimeSpan.Parse("0"), 1); this.context.DirectTweets.Add(directTweetItem1); var followerItem1 = new Follower(); followerItem1.SetProperties("A", DateTime.Parse("1/1/1987 12:00:00 AM"), "A", 1, 1, 1, "A"); this.context.Followers.Add(followerItem1); var followingItem1 = new Following(); followingItem1.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), "A", "A"); this.context.Followings.Add(followingItem1); var locationItem1 = new Location(); locationItem1.SetProperties(1, 1, 1, "A"); this.context.Locations.Add(locationItem1); var messageItem1 = new Message(); messageItem1.SetProperties("A", 1, 1); this.context.Messages.Add(messageItem1); var messengerItem1 = new Messenger(); messengerItem1.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, 1, TimeSpan.Parse("0"), 1, 1); this.context.Messengers.Add(messengerItem1); var quoteTweetItem1 = new QuoteTweet(); quoteTweetItem1.SetProperties("A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, 1, TimeSpan.Parse("0")); this.context.QuoteTweets.Add(quoteTweetItem1); var replyItem1 = new Reply(); replyItem1.SetProperties("A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, TimeSpan.Parse("0")); this.context.Replies.Add(replyItem1); var retweetItem1 = new Retweet(); retweetItem1.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, TimeSpan.Parse("0"), 1); this.context.Retweets.Add(retweetItem1); var tweetItem1 = new Tweet(); tweetItem1.SetProperties("A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1, TimeSpan.Parse("0"), 1, 1); this.context.Tweets.Add(tweetItem1); var userItem1 = new User(); userItem1.SetProperties("A", DateTime.Parse("1/1/1987 12:00:00 AM"), "A", "A", "A", "A", "A", 1, "A", "A", "A", 1, "A", "A"); this.context.Users.Add(userItem1); await this.context.SaveChangesAsync(); }
public async void Create() { Mock <ILogger <QuoteTweetRepository> > loggerMoc = QuoteTweetRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = QuoteTweetRepositoryMoc.GetContext(); var repository = new QuoteTweetRepository(loggerMoc.Object, context); var entity = new QuoteTweet(); entity.SetProperties(default(int), "B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, 1, TimeSpan.Parse("02:00:00")); await repository.Create(entity); var records = await context.Set <QuoteTweet>().ToListAsync(); records.Count.Should().Be(2); }
public async void Get() { Mock <ILogger <QuoteTweetRepository> > loggerMoc = QuoteTweetRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = QuoteTweetRepositoryMoc.GetContext(); var repository = new QuoteTweetRepository(loggerMoc.Object, context); QuoteTweet entity = new QuoteTweet(); entity.SetProperties(default(int), "B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, 1, TimeSpan.Parse("02:00:00")); context.Set <QuoteTweet>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.QuoteTweetId); record.Should().NotBeNull(); }
public async void Update_Entity_Is_Not_Tracked() { Mock <ILogger <QuoteTweetRepository> > loggerMoc = QuoteTweetRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = QuoteTweetRepositoryMoc.GetContext(); var repository = new QuoteTweetRepository(loggerMoc.Object, context); QuoteTweet entity = new QuoteTweet(); entity.SetProperties(default(int), "B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, 1, TimeSpan.Parse("02:00:00")); context.Set <QuoteTweet>().Add(entity); await context.SaveChangesAsync(); context.Entry(entity).State = EntityState.Detached; await repository.Update(entity); var records = await context.Set <QuoteTweet>().ToListAsync(); records.Count.Should().Be(2); }