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; IFollowerService service = testServer.Host.Services.GetService(typeof(IFollowerService)) as IFollowerService; var model = new ApiFollowerServerRequestModel(); model.SetProperties("B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, 1, "B", "B"); CreateResponse <ApiFollowerServerResponseModel> createdResponse = await service.Create(model); createdResponse.Success.Should().BeTrue(); ActionResponse deleteResult = await client.FollowerDeleteAsync(2); deleteResult.Success.Should().BeTrue(); ApiFollowerServerResponseModel verifyResponse = await service.Get(2); verifyResponse.Should().BeNull(); }
public HttpResponseMessage GetByFollowerId() { ItemsResponse <BaseFollower> response = new ItemsResponse <BaseFollower>(); string userId = _userService.GetCurrentUserId(); response.Items = _followerSevice.Get(userId); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
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 ApiFollowerServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; IFollowerService service = testServer.Host.Services.GetService(typeof(IFollowerService)) as IFollowerService; ApiFollowerServerResponseModel model = await service.Get(1); ApiFollowerClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties("B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, 1, "B", "B"); UpdateResponse <ApiFollowerClientResponseModel> updateResponse = await client.FollowerUpdateAsync(model.Id, request); context.Entry(context.Set <Follower>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.Id.Should().Be(1); context.Set <Follower>().ToList()[0].Blocked.Should().Be("B"); context.Set <Follower>().ToList()[0].DateFollowed.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); context.Set <Follower>().ToList()[0].FollowedUserId.Should().Be(1); context.Set <Follower>().ToList()[0].FollowingUserId.Should().Be(1); context.Set <Follower>().ToList()[0].FollowRequestStatu.Should().Be("B"); context.Set <Follower>().ToList()[0].Muted.Should().Be("B"); updateResponse.Record.Id.Should().Be(1); updateResponse.Record.Blocked.Should().Be("B"); updateResponse.Record.DateFollowed.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM")); updateResponse.Record.FollowedUserId.Should().Be(1); updateResponse.Record.FollowingUserId.Should().Be(1); updateResponse.Record.FollowRequestStatu.Should().Be("B"); updateResponse.Record.Muted.Should().Be("B"); }