public async void TestDelete()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

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

            var createModel = new ApiDeviceRequestModel();

            createModel.SetProperties("B", Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            CreateResponse <ApiDeviceResponseModel> createResult = await client.DeviceCreateAsync(createModel);

            createResult.Success.Should().BeTrue();

            ApiDeviceResponseModel getResponse = await client.DeviceGetAsync(2);

            getResponse.Should().NotBeNull();

            ActionResponse deleteResult = await client.DeviceDeleteAsync(2);

            deleteResult.Success.Should().BeTrue();

            ApiDeviceResponseModel verifyResponse = await client.DeviceGetAsync(2);

            verifyResponse.Should().BeNull();
        }
        private async Task <ApiDeviceResponseModel> CreateRecord(ApiClient client)
        {
            var model = new ApiDeviceRequestModel();

            model.SetProperties("B", Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            CreateResponse <ApiDeviceResponseModel> result = await client.DeviceCreateAsync(model);

            result.Success.Should().BeTrue();
            return(result.Record);
        }
Esempio n. 3
0
        public void MapModelToBO()
        {
            var mapper = new BOLDeviceMapper();
            ApiDeviceRequestModel model = new ApiDeviceRequestModel();

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

            response.Name.Should().Be("A");
            response.PublicId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
        }
Esempio n. 4
0
        public void MapRequestToResponse()
        {
            var mapper = new ApiDeviceModelMapper();
            var model  = new ApiDeviceRequestModel();

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

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
            response.PublicId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
        }
Esempio n. 5
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"));
        }