Exemplo n.º 1
0
      public void FindProductsByFilterMaterializeResults()
      {
         //Arrange
         var customerRepository = new StubICustomerRepository();
         var productRepository = new StubIProductRepository();
         var orderRepository = new StubIOrderRepository();
         productRepository.AllMatchingISpecificationOfProduct = (spec) =>
         {
            var book = new Book("title", "description", "publisher", "isbn");
            book.ChangeUnitPrice(10);
            book.GenerateNewIdentity();

            var software = new Software("title", "description", "license code");
            software.ChangeUnitPrice(10);
            software.GenerateNewIdentity();

            return new List<Product>()
            {
               book,
               software
            };
         };

         var salesManagement = new SalesAppService(productRepository, orderRepository, customerRepository);

         //act
         var result = salesManagement.FindProducts("filter text");

         //Assert
         Assert.IsNotNull(result);
         Assert.IsTrue(result.Count == 2);
      }
Exemplo n.º 2
0
      public void FindProductsInPageReturnNullWhenNoData()
      {
         //Arrange

         var customerRepository = new StubICustomerRepository();
         var orderRepository = new StubIOrderRepository();
         var productRepository = new StubIProductRepository();
         //productRepository.GetPagedInt32Int32ExpressionOfFuncOfProductKPropertyBoolean<string>(
         //   (index, count, order, ascending) => { return new List<Product>(); });

         productRepository.GetPagedOf1Int32Int32ExpressionOfFuncOfProductM0Boolean<string>(
            (index, count, order, @ascending) => new List<Product>());

         //productRepository.GetPagedOf1Int32Int32ExpressionOfFuncOfProductM0Boolean<string>(
         //   delegate(int index, int count, Expression<Func<Product, string>> order, bool ascending)
         //   {
         //      return new List<Product>();
         //   });

         var salesManagement = new SalesAppService(productRepository, orderRepository, customerRepository);

         //act
         var result = salesManagement.FindProducts(0, 1);

         //Assert
         Assert.IsNull(result);
      }
Exemplo n.º 3
0
      public void FindProductsInPageMaterializeResults()
      {
         //Arrange
         var customerRepository = new StubICustomerRepository();
         var productRepository = new StubIProductRepository();
         var orderRepository = new StubIOrderRepository();
         //productRepository.GetPagedInt32Int32ExpressionOfFuncOfProductKPropertyBoolean<string>(
         //   (index, count, order, ascending) =>
         //   {
         //      var book = new Book("title", "description", "publisher", "isbn");
         //      book.ChangeUnitPrice(10M);
         //      book.GenerateNewIdentity();

         //      var software = new Software("title", "description", "license code");
         //      software.ChangeUnitPrice(10);
         //      software.GenerateNewIdentity();

         //      return new List<Product>()
         //      {
         //         book,
         //         software
         //      };
         //   });

         productRepository.GetPagedOf1Int32Int32ExpressionOfFuncOfProductM0Boolean<string>(
            (index, count, order, ascending) =>
            {
               var book = new Book("title", "description", "publisher", "isbn");
               book.ChangeUnitPrice(10M);
               book.GenerateNewIdentity();

               var software = new Software("title", "description", "license code");
               software.ChangeUnitPrice(10);
               software.GenerateNewIdentity();

               return new List<Product>
               {
                  book,
                  software
               };

            });

         var salesManagement = new SalesAppService(productRepository, orderRepository, customerRepository);

         //act
         var result = salesManagement.FindProducts(0, 2);

         //Assert
         Assert.IsNotNull(result);
         Assert.IsTrue(result.Count == 2);
      }
Exemplo n.º 4
0
      public void FindProductsInPageThrowExceptionWhenPageIsInvalid()
      {
         //Arrange

         var customerRepository = new StubICustomerRepository();
         var productRepository = new StubIProductRepository();
         var orderRepository = new StubIOrderRepository();

         var salesManagement = new SalesAppService(productRepository, orderRepository, customerRepository);

         //act
         var resultInvalidPageIndex = salesManagement.FindProducts(-1, 1);
      }
        public void FindProductsInPageReturnNullWhenNoData()
        {
            //Arrange
            
            var customerRepository = new SICustomerRepository();
            var orderRepository = new SIOrderRepository();
            var productRepository = new SIProductRepository();
            productRepository.GetPagedInt32Int32ExpressionOfFuncOfProductKPropertyBoolean<string>((index, count, order, ascending) =>
            {
                return new List<Product>();
            });

            var salesManagement = new SalesAppService(productRepository, orderRepository, customerRepository);

            //act
            var result = salesManagement.FindProducts(0, 1);


            //Assert
            Assert.IsNull(result);
        }
        public void FindProductsInPageReturnNullWhenPageIsInvalid()
        {
            //Arrange
            var adapter = PrepareTypeAdapter();
            var customerRepository = new SICustomerRepository();
            var productRepository = new SIProductRepository();
            var orderRepository = new SIOrderRepository();

            var salesManagement = new SalesAppService(adapter, productRepository, orderRepository,customerRepository);

            //act
            var resultInvalidPageIndex = salesManagement.FindProducts(-1, 1);
            var resultInvalidPageCount = salesManagement.FindProducts(0, 0);

            //Assert
            Assert.IsNull(resultInvalidPageIndex);
            Assert.IsNull(resultInvalidPageCount);
        }
        public void FindProductsInPageMaterializeResults()
        {
            //Arrange
            var adapter = PrepareTypeAdapter();
            var customerRepository = new SICustomerRepository();
            var productRepository = new SIProductRepository();
            var orderRepository = new SIOrderRepository();
            productRepository.GetPagedInt32Int32ExpressionOfFuncOfProductKPropertyBoolean<string>((index, count, order, ascending) =>
            {
                return new List<Product>()
                {
                    new Book(){Id= Guid.NewGuid(),Title = "title",UnitPrice = 10,Description ="description",ISBN ="isbn",Publisher ="publisher"},
                    new Software(){Id= Guid.NewGuid(),Title = "title",UnitPrice = 10,Description ="description",LicenseCode ="license code"},
                };
            });

            var salesManagement = new SalesAppService(adapter, productRepository, orderRepository,customerRepository);

            //act
            var result = salesManagement.FindProducts(0, 2);

            //Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count == 2);
        }
        public void FindProductsByFilterMaterializeResults()
        {
            //Arrange
            var adapter = PrepareTypeAdapter();
            var customerRepository = new SICustomerRepository();
            var productRepository = new SIProductRepository();
            var orderRepository = new SIOrderRepository();
            productRepository.AllMatchingISpecificationOfProduct = (spec) =>
            {
                return new List<Product>()
                {
                    new Book(){Id= Guid.NewGuid(),Title = "title",UnitPrice = 10,Description ="description",ISBN ="isbn",Publisher ="publisher"},
                    new Software(){Id= Guid.NewGuid(),Title = "title",UnitPrice = 10,Description ="description",LicenseCode ="license code"},
                };
            };

            var salesManagement = new SalesAppService(adapter, productRepository, orderRepository,customerRepository);

            //act
            var result = salesManagement.FindProducts("filter text");

            //Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count == 2);
        }