Exemplo n.º 1
0
        public async Task <HttpResponseMessage> CreateHardware(CreateHardwareRequest createHardwareRequest)
        {
            var content = IntegrationHttpRequest.CreateContentRequest(createHardwareRequest);
            HttpResponseMessage response = await client.PostAsync(UrlBase + "api/v1/create-hardware", content);

            return(response);
        }
Exemplo n.º 2
0
        private async Task <HardwareResponse> CreatedDefaultHardware()
        {
            CreateHardwareRequest hardware = HardwareComponentsValues.CreateHardwareRequestBasic();
            var request = AutomapperSingleton.Mapper.Map <HardwareResponse>(hardware);

            IActionResult actionResult = await CreateHardware(hardware);

            ObjectResult objectResult = actionResult is ObjectResult ? actionResult as ObjectResult : null;

            if (objectResult != null && objectResult.Value is Guid)
            {
                var identifier = objectResult.Value as Guid?;

                if (identifier.HasValue)
                {
                    request.Id = identifier.Value;
                }
                else
                {
                    Assert.Fail("Return value isn't a identifier valid");
                }
            }
            else
            {
                Assert.Fail("Imposible create default record");
            }

            return(request);
        }
Exemplo n.º 3
0
        public async Task <Guid> CreateHardwareAsync(CreateHardwareRequest request)
        {
            var id = await AddAsync(_mapper.Map <DomainModel.Hardware>(request));

            await SaveAsync();

            return(id);
        }
Exemplo n.º 4
0
        public async Task TestCreateHardwareAsync(CreateHardwareRequest obj, ObjectResult resultAction)
        {
            var request = AutomapperSingleton.Mapper.Map <CreateHardwareRequest>(obj);

            HttpResponseMessage actionResult = await _hardwareAPI.CreateHardware(request);

            if (actionResult.StatusCode == HttpStatusCode.OK)
            {
                dynamic id = JsonConvert.DeserializeObject(actionResult.Content.ReadAsStringAsync().Result, resultAction.Value.GetType());
                HardwareComponentsValues.GuidAvailable = (Guid)id;
                //RecordComponentsValues.NameAvailable = obj.Name;
            }
            base.CheckAssert(actionResult, resultAction);
        }
Exemplo n.º 5
0
        public async Task TestCreateHardware(CreateHardwareRequest obj, IActionResult resultAction)
        {
            //var request = AutomapperSingleton.Mapper.Map<CreateCompanyRequest>(obj);

            IActionResult actionResult = await CreateHardware(obj);

            var objectResult = actionResult as ObjectResult;

            if (objectResult.StatusCode == 200)
            {
                dynamic id = Guid.Parse(objectResult.Value.ToString());
                HardwareComponentsValues.GuidAvailable = (Guid)id;
                //RecordComponentsValues.NameAvailable = obj.Name;
            }

            base.CheckAssert(actionResult, resultAction);
        }
Exemplo n.º 6
0
        private async Task <IActionResult> CreateHardware(CreateHardwareRequest createHardwareRequest)
        {
            var options = new DbContextOptionsBuilder <Context>()
                          .UseInMemoryDatabase(databaseName: "Hardware")
                          .Options;


            // Run the test against one instance of the context
            using (var context = new Context(options))
            {
                var repository = new HardwareRepository(context, AutomapperSingleton.Mapper);
                var service    = new HardwareService(repository, AutomapperSingleton.Mapper);
                var controller = new HardwareController(service);

                Mock <HttpRequest> mockCreateRequest = MockHttpRequest.CreateMockRequest(createHardwareRequest);
                return(await controller.CreateHardwareAsync(mockCreateRequest.Object, _logger)); //as GridController;
            }
        }
        public async Task <Guid> CreateHardwareAsync(CreateHardwareRequest request)
        {
            var id = await _hardwareRepository.CreateHardwareAsync(request);

            return(id);
        }