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();
        }
Esempio n. 2
0
        public async virtual Task <QuoteTweet> Create(QuoteTweet item)
        {
            this.Context.Set <QuoteTweet>().Add(item);
            await this.Context.SaveChangesAsync();

            this.Context.Entry(item).State = EntityState.Detached;
            return(item);
        }
Esempio n. 3
0
        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();
            await repository.Create(entity);

            var record = await context.Set <QuoteTweet>().FirstOrDefaultAsync();

            record.Should().NotBeNull();
        }
        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);
        }
Esempio n. 5
0
        public async virtual Task Delete(
            int quoteTweetId)
        {
            QuoteTweet record = await this.GetById(quoteTweetId);

            if (record == null)
            {
                return;
            }
            else
            {
                this.Context.Set <QuoteTweet>().Remove(record);
                await this.Context.SaveChangesAsync();
            }
        }
Esempio n. 6
0
        public async virtual Task Update(QuoteTweet item)
        {
            var entity = this.Context.Set <QuoteTweet>().Local.FirstOrDefault(x => x.QuoteTweetId == item.QuoteTweetId);

            if (entity == null)
            {
                this.Context.Set <QuoteTweet>().Attach(item);
            }
            else
            {
                this.Context.Entry(entity).CurrentValues.SetValues(item);
            }

            await this.Context.SaveChangesAsync();
        }
Esempio n. 7
0
        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();

            context.Set <QuoteTweet>().Add(entity);
            await context.SaveChangesAsync();

            var record = await repository.Get(entity.QuoteTweetId);

            record.Should().NotBeNull();
        }
        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();
        }
Esempio n. 9
0
        public async void Delete()
        {
            Mock <ILogger <QuoteTweetRepository> > loggerMoc = QuoteTweetRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = QuoteTweetRepositoryMoc.GetContext();
            var        repository        = new QuoteTweetRepository(loggerMoc.Object, context);
            QuoteTweet entity            = new QuoteTweet();

            context.Set <QuoteTweet>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Delete(entity.QuoteTweetId);

            QuoteTweet modifiedRecord = await context.Set <QuoteTweet>().FirstOrDefaultAsync();

            modifiedRecord.Should().BeNull();
        }
Esempio n. 10
0
        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();

            context.Set <QuoteTweet>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Update(new QuoteTweet());

            var modifiedRecord = context.Set <QuoteTweet>().FirstOrDefaultAsync();

            modifiedRecord.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);
        }