示例#1
0
        public async void unit_test_addMoney()
        {
            //Arrange
            var context  = new Mock <HttpContext>();
            var identity = new GenericIdentity("test");

            identity.AddClaim(new Claim(ClaimTypes.Name, "f8ac5f4b-d637-4bc4-acd2-cd940663f3ef"));
            var principal = new GenericPrincipal(identity, new[] { "User" });

            context.Setup(s => s.User).Returns(principal);
            _uut.ControllerContext.HttpContext = context.Object;

            WalletEntity test = new WalletEntity()
            {
                Amount = 6000
            };

            //Act
            _uut.addMoney(test);
            var result = await _uut.getBalance();

            var okResult = result as OkObjectResult;
            var content  = okResult.Value;

            //Assert
            Xunit.Assert.Equal(12000, content);
        }
        public void addNumberDecimal()
        {
            // Disponer
            WalletController controller = new WalletController();

            // Actuar
            var result = controller.addMoney(10.55M) as OkNegotiatedContentResult <Communicator>;

            // Declarar
            Assert.IsNotNull(result);
            Assert.AreEqual(true, result.Content.State);
        }
        public void addOnlyPositiveValuesInSubtractMoney()
        {
            // Disponer
            WalletController controller = new WalletController();

            // Actuar
            var result = controller.addMoney(-300) as OkNegotiatedContentResult <Communicator>;

            // Declarar
            Assert.IsNotNull(result);
            Assert.AreEqual("Solo valores positivos", result.Content.Message);
            Assert.AreEqual(false, result.Content.State);
        }
        public void Corretamount()
        {
            // Disponer
            WalletController controller = new WalletController();

            // Actuar
            var result = controller.addMoney(500) as OkNegotiatedContentResult <Communicator>;

            // Declarar
            Assert.IsNotNull(result);
            Assert.AreEqual(500, result.Content.Money);
            Assert.AreEqual(true, result.Content.State);
        }