public void AddNewCustomerReturnAdaptedDTO()
        {
            //Arrange
            var adapter = PrepareTypeAdapter();
            var countryRepository = new SICountryRepository();
            var customerRepository = new SICustomerRepository();
            customerRepository.AddCustomer = (customer) => { };
            customerRepository.UnitOfWorkGet = () =>
            {
                var uow = new SIUnitOfWork();
                uow.Commit = () => { };

                return uow;
            };

            var customerManagementService = new CustomerAppService(adapter, countryRepository, customerRepository);

            var customerDTO = new CustomerDTO()
            {
                CountryId = Guid.NewGuid(),
                FirstName = "Jhon",
                LastName = "El rojo"
            };

            //act
            var result = customerManagementService.AddNewCustomer(customerDTO);

            //Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Id != Guid.Empty);
            Assert.AreEqual(result.FirstName, customerDTO.FirstName);
            Assert.AreEqual(result.LastName, customerDTO.LastName);
        }
Ejemplo n.º 2
0
      public void AddNewCustomerThrowExceptionIfCustomerDtoIsNull()
      {
         //Arrange
         var countryRepository = new StubICountryRepository();
         var customerRepository = new StubICustomerRepository();

         var customerManagementService = new CustomerAppService(countryRepository, customerRepository);

         //act
         var result = customerManagementService.AddNewCustomer(null);

         //Assert
         Assert.IsNull(result);
      }
Ejemplo n.º 3
0
      public void AddNewCustomerThrowArgumentExceptionIfCustomerCountryInformationIsEmpty()
      {
         //Arrange
         var countryRepository = new StubICountryRepository();
         var customerRepository = new StubICustomerRepository();

         var customerManagementService = new CustomerAppService(countryRepository, customerRepository);

         var customerDto = new CustomerDto()
         {
            CountryId = Guid.Empty
         };

         //act
         var result = customerManagementService.AddNewCustomer(customerDto);
      }
Ejemplo n.º 4
0
      public void AddNewCustomerReturnAdaptedDto()
      {
         //Arrange

         var countryRepository = new StubICountryRepository();
         countryRepository.GetGuid = (guid) =>
         {
            var country = new Country("Spain", "es-ES");
            ;
            country.ChangeCurrentIdentity(guid);

            return country;
         };
         var customerRepository = new StubICustomerRepository();
         customerRepository.AddCustomer = (customer) => { };
         customerRepository.UnitOfWorkGet = () =>
         {
            var uow = new StubIUnitOfWork();
            uow.Commit = () => { };

            return uow;
         };

         var customerManagementService = new CustomerAppService(countryRepository, customerRepository);

         var customerDto = new CustomerDto()
         {
            CountryId = Guid.NewGuid(),
            FirstName = "Jhon",
            LastName = "El rojo"
         };

         //act
         var result = customerManagementService.AddNewCustomer(customerDto);

         //Assert
         Assert.IsNotNull(result);
         Assert.IsTrue(result.Id != Guid.Empty);
         Assert.AreEqual(result.FirstName, customerDto.FirstName);
         Assert.AreEqual(result.LastName, customerDto.LastName);
      }
Ejemplo n.º 5
0
      public void AddNewCustomerThrowApplicationErrorsWhenEntityIsNotValid()
      {
         //Arrange
         var countryId = Guid.NewGuid();

         var countryRepository = new StubICountryRepository();
         countryRepository.GetGuid = (guid) =>
         {
            var country = new Country("spain", "es-ES");
            country.GenerateNewIdentity();

            return country;
         };
         var customerRepository = new StubICustomerRepository();
         customerRepository.AddCustomer = (customer) => { };
         customerRepository.UnitOfWorkGet = () =>
         {
            var uow = new StubIUnitOfWork();
            uow.Commit = () => { };

            return uow;
         };

         var customerManagementService = new CustomerAppService(countryRepository, customerRepository);

         var customerDto = new CustomerDto() //missing lastname
         {
            CountryId = Guid.NewGuid(),
            FirstName = "Jhon"
         };

         //act
         var result = customerManagementService.AddNewCustomer(customerDto);
      }
        public void AddNewCustomerReturnNullIfCustomerCountryInformationIsEmpty()
        {
            //Arrange
            var adapter = PrepareTypeAdapter();
            var countryRepository = new SICountryRepository();
            var customerRepository = new SICustomerRepository();

            var customerManagementService = new CustomerAppService(adapter, countryRepository, customerRepository);

            var customerDTO = new CustomerDTO()
            {
                CountryId = Guid.Empty
            };

            //act
            var result = customerManagementService.AddNewCustomer(customerDTO);

            //Assert
            Assert.IsNull(result);
        }
        public void AddNewCustomerThrowApplicationErrorsWhenEntityIsNotValid()
        {
            //Arrange
            var adapter = PrepareTypeAdapter();
            var countryRepository = new SICountryRepository();
            var customerRepository = new SICustomerRepository();
            customerRepository.AddCustomer = (customer) => { };
            customerRepository.UnitOfWorkGet = () =>
            {
                var uow = new SIUnitOfWork();
                uow.Commit = () => { };

                return uow;
            };

            var customerManagementService = new CustomerAppService(adapter, countryRepository, customerRepository);

            var customerDTO = new CustomerDTO() //missing lastname
            {
                CountryId = Guid.NewGuid(),
                FirstName = "Jhon"
            };

            //act
            var result = customerManagementService.AddNewCustomer(customerDTO);
        }
        public void AddNewCustomerReturnNullIfCustomerDtoIsNull()
        {
            //Arrange
            var adapter = PrepareTypeAdapter();
            var countryRepository = new SICountryRepository();
            var customerRepository = new SICustomerRepository();

            var customerManagementService = new CustomerAppService(adapter, countryRepository, customerRepository);

            //act
            var result = customerManagementService.AddNewCustomer(null);

            //Assert
            Assert.IsNull(result);
        }