예제 #1
0
        public async Task Should_Return_Error_When_Null_Request()
        {
            //Arrange
            var automatFacade = new AutomatFacade(new FakeProductRepository(), new FakeCampaingRepository(), new FakeTransactionRepository());

            //Act
            var result = await automatFacade.Selection(null);

            //Assert
            Assert.Equal(1, result.Code);
        }
예제 #2
0
        public async Task Should_Return_Success_When_Request_To_CampaingGetAll()
        {
            //Arrange
            var automatFacade = new AutomatFacade(new FakeProductRepository(), new FakeCampaingRepository(), new FakeTransactionRepository());

            //Act
            var result = await automatFacade.CampaingGetAll();

            //Assert
            Assert.Equal(1, result.Count);
        }
예제 #3
0
        public async Task Should_Return_Error_When_SelectedPieces_Bigger_Than_NumberOfProducts()
        {
            //Arrange
            var automatFacade = new AutomatFacade(new FakeProductRepository(), new FakeCampaingRepository(), new FakeTransactionRepository());

            //Act
            ProductSelection productSelection = new ProductSelection();

            productSelection.Slot           = 99;
            productSelection.SugarLevel     = 0;
            productSelection.SelectedPieces = 100;
            var result = await automatFacade.Selection(productSelection);

            //Assert
            Assert.Equal(1, result.Code);
        }
예제 #4
0
        public async Task Should_Return_Error_When_Sending_Wrong_Card_Info_For_PaymentByCreditCard()
        {
            //Arrange
            var automatFacade = new AutomatFacade(new FakeProductRepository(), new FakeCampaingRepository(), new FakeTransactionRepository());

            //Act
            PaymentByCreditCardEntity paymentByCreditCardEntity = new PaymentByCreditCardEntity();

            paymentByCreditCardEntity.Pan   = "";
            paymentByCreditCardEntity.Year  = 2020;
            paymentByCreditCardEntity.Month = 12;
            var result = await automatFacade.PaymentByCreditCard(paymentByCreditCardEntity);

            //Assert
            Assert.Equal(1, result.Code);
        }
예제 #5
0
        public async Task Should_Return_Error_When_TransactionAmount_Bigger_Than_CachAmount()
        {
            //Arrange
            var automatFacade = new AutomatFacade(new FakeProductRepository(), new FakeCampaingRepository(), new FakeTransactionRepository());

            //Act
            PaymentByCashEntity paymentByCashEntity = new PaymentByCashEntity();

            paymentByCashEntity.CashAmount    = 1;
            paymentByCashEntity.Id            = 1;
            paymentByCashEntity.TransactionId = 1;
            var result = await automatFacade.PaymentByCash(paymentByCashEntity);

            //Assert
            Assert.Equal(1, result.Code);
        }
예제 #6
0
        public async Task Should_Return_Success_When_There_Is_A_Campaing()
        {
            //Arrange
            var automatFacade = new AutomatFacade(new FakeProductRepository(), new FakeCampaingRepository(), new FakeTransactionRepository());

            //Act
            ProductSelection productSelection = new ProductSelection();

            productSelection.Slot           = 1;
            productSelection.SugarLevel     = 0;
            productSelection.SelectedPieces = 1;
            var result = await automatFacade.Selection(productSelection);

            //Assert
            Assert.Equal(0, result.Code);
            Assert.Equal((decimal)4.950, result.TotalAmount);
        }
예제 #7
0
        public async Task Should_Return_Error_When_Send_Non_Product()
        {
            //Arrange
            var automatFacade = new AutomatFacade(new FakeProductRepository(), new FakeCampaingRepository(), new FakeTransactionRepository());
            var moq           = new Mock <FakeProductRepository>();

            moq.Setup(r => r.GetByIdAsync()).Returns(Task.FromResult <ProductEntity>(null));
            //Act

            ProductSelection productSelection = new ProductSelection();

            productSelection.Slot           = 99;
            productSelection.SugarLevel     = 0;
            productSelection.SelectedPieces = 100;
            var result = await automatFacade.Selection(productSelection);

            //Assert
            Assert.Equal(1, result.Code);
        }