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;

            ITweetService service = testServer.Host.Services.GetService(typeof(ITweetService)) as ITweetService;
            var           model   = new ApiTweetServerRequestModel();

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

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

            ActionResponse deleteResult = await client.TweetDeleteAsync(2);

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

            verifyResponse.Should().BeNull();
        }
Exemple #2
0
        public void MapServerRequestToResponse()
        {
            var mapper = new ApiTweetServerModelMapper();
            var model  = new ApiTweetServerRequestModel();

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

            response.Should().NotBeNull();
            response.Content.Should().Be("A");
            response.Date.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.LocationId.Should().Be(1);
            response.Time.Should().Be(TimeSpan.Parse("01:00:00"));
            response.UserUserId.Should().Be(1);
        }
Exemple #3
0
        public void CreatePatch()
        {
            var mapper = new ApiTweetServerModelMapper();
            var model  = new ApiTweetServerRequestModel();

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

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

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