Exemplo n.º 1
0
        public async Task Test_Post_When_Model_Is_Null_Then_Returns_BadRequest()
        {
            var bonusRepository = new Mock <IBonusRepository>();
            var bonusRecipients = new Mock <BonusRecipients>();

            var remunerationController = new RemunerationController(bonusRepository.Object)
            {
                Request = new HttpRequestMessage()
                {
                    Properties = { { HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration() } }
                }
            };
            var result = await remunerationController.Post(null);

            var response = await result.ExecuteAsync(CancellationToken.None);

            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
        }
Exemplo n.º 2
0
        public async Task Test_Post_When_Data_Not_Saved_Then_Returns_BadRequest()
        {
            var bonusRepository = new Mock <IBonusRepository>();
            var bonusRecipients = new Mock <BonusRecipients>();

            bonusRepository.Setup(x => x.SaveAsync(It.IsAny <List <EmployeeBonus> >())).ReturnsAsync(false);

            var remunerationController = new RemunerationController(bonusRepository.Object)
            {
                Request = new HttpRequestMessage()
                {
                    Properties = { { HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration() } }
                }
            };

            var result = await remunerationController.Post(bonusRecipients.Object);

            var response = await result.ExecuteAsync(CancellationToken.None);

            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
        }