public virtual async void TestDelete() { var builder = new WebHostBuilder() .UseEnvironment("Production") .UseStartup <TestStartup>(); TestServer testServer = new TestServer(builder); var client = new ApiClient(testServer.CreateClient()); client.SetBearerToken(JWTTestHelper.GenerateBearerToken()); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; IDirectTweetService service = testServer.Host.Services.GetService(typeof(IDirectTweetService)) as IDirectTweetService; var model = new ApiDirectTweetServerRequestModel(); model.SetProperties("B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, TimeSpan.Parse("02:00:00")); CreateResponse <ApiDirectTweetServerResponseModel> createdResponse = await service.Create(model); createdResponse.Success.Should().BeTrue(); ActionResponse deleteResult = await client.DirectTweetDeleteAsync(2); deleteResult.Success.Should().BeTrue(); ApiDirectTweetServerResponseModel verifyResponse = await service.Get(2); verifyResponse.Should().BeNull(); }
public AbstractDirectTweetController( ApiSettings settings, ILogger <AbstractDirectTweetController> logger, ITransactionCoordinator transactionCoordinator, IDirectTweetService directTweetService, IApiDirectTweetModelMapper directTweetModelMapper ) : base(settings, logger, transactionCoordinator) { this.DirectTweetService = directTweetService; this.DirectTweetModelMapper = directTweetModelMapper; }
public DirectTweetController( ApiSettings settings, ILogger <DirectTweetController> logger, ITransactionCoordinator transactionCoordinator, IDirectTweetService directTweetService, IApiDirectTweetServerModelMapper directTweetModelMapper ) : base(settings, logger, transactionCoordinator) { this.DirectTweetService = directTweetService; this.DirectTweetModelMapper = directTweetModelMapper; this.BulkInsertLimit = 250; this.MaxLimit = 1000; this.DefaultLimit = 250; }
public virtual async void TestUpdate() { var builder = new WebHostBuilder() .UseEnvironment("Production") .UseStartup <TestStartup>(); TestServer testServer = new TestServer(builder); var client = new ApiClient(testServer.CreateClient()); client.SetBearerToken(JWTTestHelper.GenerateBearerToken()); var mapper = new ApiDirectTweetServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; IDirectTweetService service = testServer.Host.Services.GetService(typeof(IDirectTweetService)) as IDirectTweetService; ApiDirectTweetServerResponseModel model = await service.Get(1); ApiDirectTweetClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties("B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, TimeSpan.Parse("02:00:00")); UpdateResponse <ApiDirectTweetClientResponseModel> updateResponse = await client.DirectTweetUpdateAsync(model.TweetId, request); context.Entry(context.Set <DirectTweet>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.TweetId.Should().Be(1); context.Set <DirectTweet>().ToList()[0].Content.Should().Be("B"); context.Set <DirectTweet>().ToList()[0].Date.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); context.Set <DirectTweet>().ToList()[0].TaggedUserId.Should().Be(1); context.Set <DirectTweet>().ToList()[0].Time.Should().Be(TimeSpan.Parse("02:00:00")); updateResponse.Record.TweetId.Should().Be(1); updateResponse.Record.Content.Should().Be("B"); updateResponse.Record.Date.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); updateResponse.Record.TaggedUserId.Should().Be(1); updateResponse.Record.Time.Should().Be(TimeSpan.Parse("02:00:00")); }