Exemplo n.º 1
0
        public void TestCreateCustomer()
        {
            string date = DateTime.Now.ToString();

            Moip.Models.CustomerRequest customerRequest = Helpers.RequestsCreator.CreateCustomerRequest(date);

            Moip.Models.CustomerResponse customerResponse = controller.CreateCustomer(customerRequest);

            Assert.NotNull(customerResponse.Id, "Id should not be null");
            Assert.AreEqual("OFulanoDeTal" + date, customerResponse.OwnId, "Should match exactly (string literal match)");
            Assert.AreEqual("Fulano de Tal", customerResponse.Fullname, "Should match exactly (string literal match)");
            Assert.AreEqual("1990-01-01", customerResponse.BirthDate, "Should match exactly (string literal match)");
            Assert.AreEqual("*****@*****.**", customerResponse.Email, "Should match exactly (string literal match)");
            Assert.AreEqual("Rua test", customerResponse.ShippingAddress.Street, "Should match exactly (string literal match)");
            Assert.AreEqual("123", customerResponse.ShippingAddress.StreetNumber, "Should match exactly (string literal match)");
            Assert.AreEqual("Ap test", customerResponse.ShippingAddress.Complement, "Should match exactly (string literal match)");
            Assert.AreEqual("Bairro test", customerResponse.ShippingAddress.District, "Should match exactly (string literal match)");
            Assert.AreEqual("TestCity", customerResponse.ShippingAddress.City, "Should match exactly (string literal match)");
            Assert.AreEqual("SP", customerResponse.ShippingAddress.State, "Should match exactly (string literal match)");
            Assert.AreEqual("BRA", customerResponse.ShippingAddress.Country, "Should match exactly (string literal match)");
            Assert.AreEqual("01234000", customerResponse.ShippingAddress.ZipCode, "Should match exactly (string literal match)");
            Assert.AreEqual("55", customerResponse.Phone.CountryCode, "Should match exactly (string literal match)");
            Assert.AreEqual("11", customerResponse.Phone.AreaCode, "Should match exactly (string literal match)");
            Assert.AreEqual("66778899", customerResponse.Phone.Number, "Should match exactly (string literal match)");
            Assert.AreEqual("CPF", customerResponse.TaxDocument.Type, "Should match exactly (string literal match)");
            Assert.AreEqual("33333333333", customerResponse.TaxDocument.Number, "Should match exactly (string literal match)");
        }
Exemplo n.º 2
0
        public void Create_Should_Return_As_201CreatedResult()
        {
            //Arrange
            _mediator.Setup(s => s.Send(It.IsAny <CreateCustomerCommand>(), default)).Returns(Task.FromResult(_createCustomerDataResponse.Object));
            _createCustomerDataResponse.Setup(t => t.Success).Returns(true);
            _createCustomerDataResponse.Setup(t => t.StatusCode).Returns(StatusCodes.Status201Created);
            _createCustomerDataResponse.Setup(s => s.Data).Returns(_createCustomerResponse.Object);
            //Act
            var actual = _sut.CreateCustomer(_createCustomerRequest).GetAwaiter().GetResult();

            //Assert
            actual.GetType().Should().Equals(StatusCodes.Status201Created);
        }
        public async Task CustomerController_CreateCustomer_Ok()
        {
            var db         = _contextBuilder.ConfigureInMemory().Build();
            var repository = new Repository <Models.Customer>(db);
            var controller = new CustomersController(repository);
            var request    = A.New <Customer>();
            var response   = (await controller.CreateCustomer(request)).Result as OkObjectResult;

            var values = Convert.ToInt32(response.Value);

            values.Should().Be(request.Id);
        }
        private void CreateCustomerShouldReturnOk()
        {
            var customerCreateCmd = GetCustomerCreateCmd();

            var createdCustomer = GetCreatedCustomer();

            _customerService.Setup(x => x.Create(It.IsAny <CustomerCreateCmd>()))
            .Returns(createdCustomer);


            var response = _customersController.CreateCustomer(customerCreateCmd);

            var result = Assert.IsType <CreatedResult>(response);

            Assert.Equal(201, result.StatusCode);
            Assert.NotNull(result.Value);

            var responseData = Assert.IsType <Customer>(result.Value);

            Assert.NotNull(responseData);
            Assert.NotNull(responseData.Id);
            Assert.NotNull(responseData.FirstName);
        }
Exemplo n.º 5
0
        public void CreateCustomer_ValidCustomerCreated_ReturnCreated()
        {
            Customer customer = new Customer()
            {
                CustomerId = 1
            };

            HttpMethod test = new HttpMethod("Test");

            _controller.Request       = new HttpRequestMessage(test, "/");
            _controller.Configuration = new HttpConfiguration();

            var result = _controller.CreateCustomer(customer) as CreatedNegotiatedContentResult <Customer>;

            Assert.AreEqual(customer.CustomerId, result.Content.CustomerId);
        }
        public void CreateCustomer_ValidCustomerCreated_ReturnCreated()
        {
            using (new TransactionScope())
            {
                Customer customer = CreateTestObjects.CreateNewCustomer("Kiira", "Toivonen", "Helsinki", "Helsingintie 16");

                HttpMethod test = new HttpMethod("Test");
                _controller.Request       = new HttpRequestMessage(test, "/");
                _controller.Configuration = new HttpConfiguration();

                var result         = _controller.CreateCustomer(customer) as CreatedNegotiatedContentResult <Customer>;
                var customerResult = result.Content;

                Assert.IsNotNull(customerResult);
                Assert.AreEqual(customer.CustomerId, customerResult.CustomerId);
            }
        }
Exemplo n.º 7
0
        public void CreateCustomer_CreateCustomerCalled()
        {
            _controller.CreateCustomer(new Customer());

            _customerRepository.Received(1).CreateCustomer(Arg.Any <Customer>());
        }