Beispiel #1
0
        public void MapClientRequestToResponse()
        {
            var mapper = new ApiCityModelMapper();
            var model  = new ApiCityClientRequestModel();

            model.SetProperties("A", 1);
            ApiCityClientResponseModel response = mapper.MapClientRequestToResponse(1, model);

            response.Should().NotBeNull();
            response.Name.Should().Be("A");
            response.ProvinceId.Should().Be(1);
        }
        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());
            ApiCityClientResponseModel response = await client.CityGetAsync(default(int));

            response.Should().BeNull();
        }
        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;

            ApiCityClientResponseModel response = await client.CityGetAsync(1);

            response.Should().NotBeNull();
            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
            response.ProvinceId.Should().Be(1);
        }