コード例 #1
0
        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);
        }
コード例 #2
0
        public async Task GetAddressByIdAsync_ReturnCustomerAddressViewModelTestAsync()
        {
            int id         = 1;
            var customerId = CustomerViewModelMock.GetCustomerId(id);

            _customerRepositoryMock.Setup(x => x.GetAddressByIdAsync(id))
            .ReturnsAsync(CustomerMock.GetCustomerAddress());

            _mapperMock.Setup(x => x.Map <CustomerAddressViewModel>(It.IsAny <CustomerAddress>()))
            .Returns(CustomerViewModelMock.GetCustomerAddress());

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

            var customeMethod = await customerService.GetAddressByIdAsync(customerId);

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

            Assert.NotNull(customerResult);
        }
コード例 #3
0
        public async Task GetAddressByNameAsync_ReturnCustomerAddressViewModelTestAsync()
        {
            var name         = "Diuor PleaBolosmakh";
            var customerName = CustomerViewModelMock.GetCustomerName(name);

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

            _mapperMock.Setup(x => x.Map <CustomerAddressViewModel>(It.IsAny <CustomerAddress>()))
            .Returns(CustomerViewModelMock.GetCustomerAddress());

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

            var customeMethod = await customerService.GetAddressByNameAsync(customerName);

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

            Assert.NotNull(customerResult);
        }