Exemple #1
0
        public void MapResponseToRequest()
        {
            var mapper = new ApiDeviceModelMapper();
            var model  = new ApiDeviceResponseModel();

            model.SetProperties(1, "A", Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            ApiDeviceRequestModel response = mapper.MapResponseToRequest(model);

            response.Name.Should().Be("A");
            response.PublicId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
        }
        public async void TestUpdate()
        {
            var model = await this.CreateRecord();

            ApiDeviceModelMapper mapper = new ApiDeviceModelMapper();

            UpdateResponse <ApiDeviceResponseModel> updateResponse = await this.Client.DeviceUpdateAsync(model.Id, mapper.MapResponseToRequest(model));

            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();

            await this.Cleanup();
        }
Exemple #3
0
        public void CreatePatch()
        {
            var mapper = new ApiDeviceModelMapper();
            var model  = new ApiDeviceRequestModel();

            model.SetProperties("A", Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));

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

            patch.ApplyTo(response);
            response.Name.Should().Be("A");
            response.PublicId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
        }
Exemple #4
0
        public void MapClientResponseToRequest()
        {
            var mapper = new ApiDeviceModelMapper();
            var model  = new ApiDeviceClientResponseModel();

            model.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), true, "A", Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            ApiDeviceClientRequestModel response = mapper.MapClientResponseToRequest(model);

            response.Should().NotBeNull();
            response.DateOfLastPing.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.IsActive.Should().Be(true);
            response.Name.Should().Be("A");
            response.PublicId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
        }
        public async void TestUpdate()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

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

            ApiDeviceResponseModel model = await client.DeviceGetAsync(1);

            ApiDeviceModelMapper mapper = new ApiDeviceModelMapper();

            UpdateResponse <ApiDeviceResponseModel> updateResponse = await client.DeviceUpdateAsync(model.Id, mapper.MapResponseToRequest(model));

            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
        }