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;

            IRetweetService service = testServer.Host.Services.GetService(typeof(IRetweetService)) as IRetweetService;
            var             model   = new ApiRetweetServerRequestModel();

            model.SetProperties(DateTime.Parse("1/1/1988 12:00:00 AM"), 1, TimeSpan.Parse("02:00:00"), 1);
            CreateResponse <ApiRetweetServerResponseModel> createdResponse = await service.Create(model);

            createdResponse.Success.Should().BeTrue();

            ActionResponse deleteResult = await client.RetweetDeleteAsync(2);

            deleteResult.Success.Should().BeTrue();
            ApiRetweetServerResponseModel verifyResponse = await service.Get(2);

            verifyResponse.Should().BeNull();
        }
Beispiel #2
0
        public void MapServerRequestToResponse()
        {
            var mapper = new ApiRetweetServerModelMapper();
            var model  = new ApiRetweetServerRequestModel();

            model.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), 1, TimeSpan.Parse("01:00:00"), 1);
            ApiRetweetServerResponseModel response = mapper.MapServerRequestToResponse(1, model);

            response.Should().NotBeNull();
            response.Date.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.RetwitterUserId.Should().Be(1);
            response.Time.Should().Be(TimeSpan.Parse("01:00:00"));
            response.TweetTweetId.Should().Be(1);
        }
Beispiel #3
0
        public void CreatePatch()
        {
            var mapper = new ApiRetweetServerModelMapper();
            var model  = new ApiRetweetServerRequestModel();

            model.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), 1, TimeSpan.Parse("01:00:00"), 1);

            JsonPatchDocument <ApiRetweetServerRequestModel> patch = mapper.CreatePatch(model);
            var response = new ApiRetweetServerRequestModel();

            patch.ApplyTo(response);
            response.Date.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.RetwitterUserId.Should().Be(1);
            response.Time.Should().Be(TimeSpan.Parse("01:00:00"));
            response.TweetTweetId.Should().Be(1);
        }