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

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

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            var mapper = new ApiCallPersonServerModelMapper();
            ApplicationDbContext             context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            ICallPersonService               service = testServer.Host.Services.GetService(typeof(ICallPersonService)) as ICallPersonService;
            ApiCallPersonServerResponseModel model   = await service.Get(1);

            ApiCallPersonClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties("B", 1, 1);

            UpdateResponse <ApiCallPersonClientResponseModel> updateResponse = await client.CallPersonUpdateAsync(model.Id, request);

            context.Entry(context.Set <CallPerson>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <CallPerson>().ToList()[0].Note.Should().Be("B");
            context.Set <CallPerson>().ToList()[0].PersonId.Should().Be(1);
            context.Set <CallPerson>().ToList()[0].PersonTypeId.Should().Be(1);

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.Note.Should().Be("B");
            updateResponse.Record.PersonId.Should().Be(1);
            updateResponse.Record.PersonTypeId.Should().Be(1);
        }
Esempio n. 2
0
        public virtual async void TestCreate()
        {
            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;

            var model = new ApiCallPersonClientRequestModel();

            model.SetProperties("B", 1, 1);
            CreateResponse <ApiCallPersonClientResponseModel> result = await client.CallPersonCreateAsync(model);

            result.Success.Should().BeTrue();
            result.Record.Should().NotBeNull();
            context.Set <CallPerson>().ToList()[1].Note.Should().Be("B");
            context.Set <CallPerson>().ToList()[1].PersonId.Should().Be(1);
            context.Set <CallPerson>().ToList()[1].PersonTypeId.Should().Be(1);

            result.Record.Note.Should().Be("B");
            result.Record.PersonId.Should().Be(1);
            result.Record.PersonTypeId.Should().Be(1);
        }
Esempio n. 3
0
        public virtual ApiCallPersonClientRequestModel MapServerResponseToClientRequest(
            ApiCallPersonServerResponseModel response)
        {
            var request = new ApiCallPersonClientRequestModel();

            request.SetProperties(
                response.Note,
                response.PersonId,
                response.PersonTypeId);
            return(request);
        }
        public void MapClientResponseToRequest()
        {
            var mapper = new ApiCallPersonModelMapper();
            var model  = new ApiCallPersonClientResponseModel();

            model.SetProperties(1, "A", 1, 1);
            ApiCallPersonClientRequestModel response = mapper.MapClientResponseToRequest(model);

            response.Should().NotBeNull();
            response.Note.Should().Be("A");
            response.PersonId.Should().Be(1);
            response.PersonTypeId.Should().Be(1);
        }