Ejemplo n.º 1
0
        public async Task LoadCustomersIsSuccess()
        {
            //Arrange
            var viewRecords      = Auxilaries.GenerateCustomers();
            var mockCustomerRepo = new Mock <ICustomerRepository>();

            mockCustomerRepo
            .Setup(x => x.LoadCustomersAsync()).Returns(Task.FromResult(viewRecords));

            //Act
            CustomerController customerController = new CustomerController(mockCustomerRepo.Object);
            var output = await customerController.LoadCustomers();

            var result          = output.Result as OkObjectResult;
            var expectedRecords = result.Value as IEnumerable <CustomerViewModel>;

            //Assert
            NUnit.Framework.Assert.NotNull(output);
            Assert.Equal(viewRecords.Count(), expectedRecords.Count());
            mockCustomerRepo.VerifyAll();
        }
Ejemplo n.º 2
0
        public async Task LoadCustomersWithPagingIsSuccess()
        {
            //Arrange
            var customerList     = Auxilaries.GenerateCustomersList();
            var mockCustomerRepo = new Mock <ICustomerRepository>();

            mockCustomerRepo
            .Setup(x => x.LoadCustomersWithPagingAsync(It.IsAny <PagingParameters>())).Returns(Task.FromResult(customerList));

            //Act
            CustomerController customerController = new CustomerController(mockCustomerRepo.Object);
            var output = await customerController.LoadCustomersWithPaging(new PagingParameters());

            var result          = output.Result as OkObjectResult;
            var expectedRecords = result.Value as CustomerList;

            //Assert
            NUnit.Framework.Assert.NotNull(output);
            Assert.Equal(1, expectedRecords.CurrentPage);
            Assert.Equal(200, expectedRecords.TotalCount);
            Assert.Equal(10, expectedRecords.PageSize);
            Assert.Equal(20, expectedRecords.TotalPages);
            mockCustomerRepo.VerifyAll();
        }