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 virtual Task <DirectTweet> Create(DirectTweet item)
        {
            this.Context.Set <DirectTweet>().Add(item);
            await this.Context.SaveChangesAsync();

            this.Context.Entry(item).State = EntityState.Detached;
            return(item);
        }
Exemple #3
0
        public async void Create()
        {
            Mock <ILogger <DirectTweetRepository> > loggerMoc = DirectTweetRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = DirectTweetRepositoryMoc.GetContext();
            var repository = new DirectTweetRepository(loggerMoc.Object, context);

            var entity = new DirectTweet();
            await repository.Create(entity);

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

            record.Should().NotBeNull();
        }
        public async void Create()
        {
            Mock <ILogger <DirectTweetRepository> > loggerMoc = DirectTweetRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = DirectTweetRepositoryMoc.GetContext();
            var repository = new DirectTweetRepository(loggerMoc.Object, context);

            var entity = new DirectTweet();

            entity.SetProperties(default(int), "B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, TimeSpan.Parse("02:00:00"));
            await repository.Create(entity);

            var records = await context.Set <DirectTweet>().ToListAsync();

            records.Count.Should().Be(2);
        }
Exemple #5
0
        public async void Get()
        {
            Mock <ILogger <DirectTweetRepository> > loggerMoc = DirectTweetRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = DirectTweetRepositoryMoc.GetContext();
            var repository = new DirectTweetRepository(loggerMoc.Object, context);

            DirectTweet entity = new DirectTweet();

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

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

            record.Should().NotBeNull();
        }
        public async virtual Task Delete(
            int tweetId)
        {
            DirectTweet record = await this.GetById(tweetId);

            if (record == null)
            {
                return;
            }
            else
            {
                this.Context.Set <DirectTweet>().Remove(record);
                await this.Context.SaveChangesAsync();
            }
        }
        public async virtual Task Update(DirectTweet item)
        {
            var entity = this.Context.Set <DirectTweet>().Local.FirstOrDefault(x => x.TweetId == item.TweetId);

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

            await this.Context.SaveChangesAsync();
        }
        public async void Get()
        {
            Mock <ILogger <DirectTweetRepository> > loggerMoc = DirectTweetRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = DirectTweetRepositoryMoc.GetContext();
            var repository = new DirectTweetRepository(loggerMoc.Object, context);

            DirectTweet entity = new DirectTweet();

            entity.SetProperties(default(int), "B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, TimeSpan.Parse("02:00:00"));
            context.Set <DirectTweet>().Add(entity);
            await context.SaveChangesAsync();

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

            record.Should().NotBeNull();
        }
Exemple #9
0
        public async void Delete()
        {
            Mock <ILogger <DirectTweetRepository> > loggerMoc = DirectTweetRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = DirectTweetRepositoryMoc.GetContext();
            var         repository       = new DirectTweetRepository(loggerMoc.Object, context);
            DirectTweet entity           = new DirectTweet();

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

            await repository.Delete(entity.TweetId);

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

            modifiedRecord.Should().BeNull();
        }
Exemple #10
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <DirectTweetRepository> > loggerMoc = DirectTweetRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = DirectTweetRepositoryMoc.GetContext();
            var         repository       = new DirectTweetRepository(loggerMoc.Object, context);
            DirectTweet entity           = new DirectTweet();

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

            await repository.Update(new DirectTweet());

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

            modifiedRecord.Should().NotBeNull();
        }
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <DirectTweetRepository> > loggerMoc = DirectTweetRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = DirectTweetRepositoryMoc.GetContext();
            var         repository       = new DirectTweetRepository(loggerMoc.Object, context);
            DirectTweet entity           = new DirectTweet();

            entity.SetProperties(default(int), "B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, TimeSpan.Parse("02:00:00"));
            context.Set <DirectTweet>().Add(entity);
            await context.SaveChangesAsync();

            context.Entry(entity).State = EntityState.Detached;

            await repository.Update(entity);

            var records = await context.Set <DirectTweet>().ToListAsync();

            records.Count.Should().Be(2);
        }