Exemple #1
0
        public virtual async void TestGetNotFound()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            ApiCommentClientResponseModel response = await client.CommentGetAsync(default(int));

            response.Should().BeNull();
        }
Exemple #2
0
        public void MapClientRequestToResponse()
        {
            var mapper = new ApiCommentModelMapper();
            var model  = new ApiCommentClientRequestModel();

            model.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, "A", 1);
            ApiCommentClientResponseModel response = mapper.MapClientRequestToResponse(1, model);

            response.Should().NotBeNull();
            response.CreationDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.PostId.Should().Be(1);
            response.Score.Should().Be(1);
            response.Text.Should().Be("A");
            response.UserId.Should().Be(1);
        }
Exemple #3
0
        public virtual async void TestGetFound()
        {
            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;

            ApiCommentClientResponseModel response = await client.CommentGetAsync(1);

            response.Should().NotBeNull();
            response.CreationDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Id.Should().Be(1);
            response.PostId.Should().Be(1);
            response.Score.Should().Be(1);
            response.Text.Should().Be("A");
            response.UserId.Should().Be(1);
        }