コード例 #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 ApiLinkLogServerModelMapper();
            ApplicationDbContext          context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            ILinkLogService               service = testServer.Host.Services.GetService(typeof(ILinkLogService)) as ILinkLogService;
            ApiLinkLogServerResponseModel model   = await service.Get(1);

            ApiLinkLogClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties(DateTime.Parse("1/1/1988 12:00:00 AM"), 1, "B");

            UpdateResponse <ApiLinkLogClientResponseModel> updateResponse = await client.LinkLogUpdateAsync(model.Id, request);

            context.Entry(context.Set <LinkLog>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <LinkLog>().ToList()[0].DateEntered.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <LinkLog>().ToList()[0].LinkId.Should().Be(1);
            context.Set <LinkLog>().ToList()[0].Log.Should().Be("B");

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.DateEntered.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            updateResponse.Record.LinkId.Should().Be(1);
            updateResponse.Record.Log.Should().Be("B");
        }
コード例 #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 ApiLinkLogClientRequestModel();

            model.SetProperties(DateTime.Parse("1/1/1988 12:00:00 AM"), 1, "B");
            CreateResponse <ApiLinkLogClientResponseModel> result = await client.LinkLogCreateAsync(model);

            result.Success.Should().BeTrue();
            result.Record.Should().NotBeNull();
            context.Set <LinkLog>().ToList()[1].DateEntered.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <LinkLog>().ToList()[1].LinkId.Should().Be(1);
            context.Set <LinkLog>().ToList()[1].Log.Should().Be("B");

            result.Record.DateEntered.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            result.Record.LinkId.Should().Be(1);
            result.Record.Log.Should().Be("B");
        }
コード例 #3
0
        public virtual ApiLinkLogClientRequestModel MapServerResponseToClientRequest(
            ApiLinkLogServerResponseModel response)
        {
            var request = new ApiLinkLogClientRequestModel();

            request.SetProperties(
                response.DateEntered,
                response.LinkId,
                response.Log);
            return(request);
        }
コード例 #4
0
        public void MapClientRequestToResponse()
        {
            var mapper = new ApiLinkLogModelMapper();
            var model  = new ApiLinkLogClientRequestModel();

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

            response.Should().NotBeNull();
            response.DateEntered.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.LinkId.Should().Be(1);
            response.Log.Should().Be("A");
        }