Ejemplo n.º 1
0
        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;

            IRateService service = testServer.Host.Services.GetService(typeof(IRateService)) as IRateService;
            var          model   = new ApiRateServerRequestModel();

            model.SetProperties(2m, 1, 1);
            CreateResponse <ApiRateServerResponseModel> createdResponse = await service.Create(model);

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

            ActionResponse deleteResult = await client.RateDeleteAsync(2);

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

            verifyResponse.Should().BeNull();
        }
        public void MapServerRequestToResponse()
        {
            var mapper = new ApiRateServerModelMapper();
            var model  = new ApiRateServerRequestModel();

            model.SetProperties(1m, 1, 1);
            ApiRateServerResponseModel response = mapper.MapServerRequestToResponse(1, model);

            response.Should().NotBeNull();
            response.AmountPerMinute.Should().Be(1m);
            response.TeacherId.Should().Be(1);
            response.TeacherSkillId.Should().Be(1);
        }
        public void CreatePatch()
        {
            var mapper = new ApiRateServerModelMapper();
            var model  = new ApiRateServerRequestModel();

            model.SetProperties(1m, 1, 1);

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

            patch.ApplyTo(response);
            response.AmountPerMinute.Should().Be(1m);
            response.TeacherId.Should().Be(1);
            response.TeacherSkillId.Should().Be(1);
        }