public async Task Post_HttpStatusCodeUnauthorizedTestAsync()
        {
            var customer = CustomerViewModelMock.GetCustomer();

            var response = await _httpClient.PostAsync("/api/v1/customers", new StringContent(JsonConvert.SerializeObject(customer)));

            Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
        }
        public async Task Delete_NotFoundTestAsync()
        {
            var id         = 1;
            var customerId = CustomerViewModelMock.GetCustomerId(id);
            var customer   = CustomerViewModelMock.GetCustomer();

            var customerController = new CustomerController(_customerServiceMock.Object);
            var customerService    = await customerController.Delete(customerId);

            var actionResult = Assert.IsType <NotFoundResult>(customerService);

            Assert.Equal(StatusCodes.Status404NotFound, actionResult.StatusCode);
        }
        public void Post_FailTestAsync()
        {
            CustomerViewModel customer = null;

            _customerServiceMock.Setup(x => x.Add(customer))
            .Returns(CustomerViewModelMock.GetCustomer());

            var customerController = new CustomerController(_customerServiceMock.Object);
            var customerService    = customerController.Post(customer);

            var actionResult = Assert.IsType <NotFoundResult>(customerService.Result);

            Assert.Equal(StatusCodes.Status404NotFound, actionResult.StatusCode);
        }
        public async Task Put_NotFoundTestAsync()
        {
            var id       = 1;
            var customer = CustomerViewModelMock.GetCustomer();

            _customerServiceMock.Setup(x => x.Update(customer));

            var customerController = new CustomerController(_customerServiceMock.Object);
            var customerService    = await customerController.Put(id, customer);

            var actionResult = Assert.IsType <NotFoundResult>(customerService);

            Assert.Equal(StatusCodes.Status404NotFound, actionResult.StatusCode);
        }
        public void Remove_SucessTestAsync()
        {
            var customer = CustomerViewModelMock.GetCustomer();

            _mapperMock.Setup(x => x.Map <Customer>(It.IsAny <CustomerViewModel>()))
            .Returns(CustomerMock.GetCustomer());

            var customerService = new CustomerService(_customerRepositoryMock.Object,
                                                      _viaCEPServiceMock.Object, _domainNotificationMock.Object,
                                                      _unitOfWorkMock.Object, _mapperMock.Object);

            customerService.Remove(customer);

            Assert.NotNull(customer);
        }
        public void Post_SucessTestAsync()
        {
            var customer = CustomerViewModelMock.GetCustomer();

            _customerServiceMock.Setup(x => x.Add(customer))
            .Returns(CustomerViewModelMock.GetCustomer());

            var customerController = new CustomerController(_customerServiceMock.Object);
            var customerService    = customerController.Post(customer);

            var actionResult = Assert.IsType <CreatedResult>(customerService.Result);
            var actionValue  = Assert.IsType <CustomerViewModel>(actionResult.Value);

            Assert.NotNull(actionValue);
            Assert.Equal(StatusCodes.Status201Created, actionResult.StatusCode);
        }
        public async Task Delete_SucessTestAsync()
        {
            var id         = 1;
            var customerId = CustomerViewModelMock.GetCustomerId(id);
            var customer   = CustomerViewModelMock.GetCustomer();

            _customerServiceMock.Setup(x => x.GetByIdAsync(customerId))
            .ReturnsAsync(customer);

            _customerServiceMock.Setup(x => x.Remove(customer));

            var customerController = new CustomerController(_customerServiceMock.Object);
            var customerService    = await customerController.Delete(customerId);

            var actionResult = Assert.IsType <NoContentResult>(customerService);

            Assert.Equal(StatusCodes.Status204NoContent, actionResult.StatusCode);
        }
        public async Task GetById_ReturnCustomerViewModelTestAsync()
        {
            int id         = 1;
            var customerId = CustomerViewModelMock.GetCustomerId(id);

            _customerRepositoryMock.Setup(x => x.GetByIdAsync(id))
            .ReturnsAsync(CustomerMock.GetCustomer());

            _mapperMock.Setup(x => x.Map <CustomerViewModel>(It.IsAny <Customer>()))
            .Returns(CustomerViewModelMock.GetCustomer());

            var customerService = new CustomerService(_customerRepositoryMock.Object,
                                                      _viaCEPServiceMock.Object, _domainNotificationMock.Object,
                                                      _unitOfWorkMock.Object, _mapperMock.Object);

            var customeMethod = await customerService.GetByIdAsync(customerId);

            var customerResult = Assert.IsAssignableFrom <CustomerViewModel>(customeMethod);

            Assert.NotNull(customerResult);
        }
        public void Add_ReturnCustomerViewModelTestAsync()
        {
            var customer = CustomerViewModelMock.GetCustomer();

            _mapperMock.Setup(x => x.Map <Customer>(It.IsAny <CustomerViewModel>()))
            .Returns(CustomerMock.GetCustomer());

            _mapperMock.Setup(x => x.Map <CustomerViewModel>(It.IsAny <Customer>()))
            .Returns(CustomerViewModelMock.GetCustomer());

            _customerRepositoryMock.Setup(x => x.GetByNameAsync(customer.Name))
            .ReturnsAsync(CustomerMock.GetCustomerAddress());

            var customerService = new CustomerService(_customerRepositoryMock.Object,
                                                      _viaCEPServiceMock.Object, _domainNotificationMock.Object,
                                                      _unitOfWorkMock.Object, _mapperMock.Object);

            customerService.Add(customer);

            Assert.NotNull(customer);
        }