Ejemplo n.º 1
0
        public void Should_Be_Able_To_Update_The_Price_Of_A_Call()
        {
            var data = CallViewModelFaker.GenerateCallViewModel();

            var call = CallFaker.GenerateCall(data);

            call.PricePerMinute = 4.30m;

            var updatedCall = call;

            updatedCall.PricePerMinute = data.PricePerMinute;

            var updatedCallViewModel = data;

            updatedCallViewModel.PricePerMinute = updatedCall.PricePerMinute;

            callsRepository.Setup(x =>
                                  x.FindByFromToAreaCode(data.FromAreaCode, data.ToAreaCode)
                                  ).Returns(call);
            callsRepository.Setup(x => x.SaveChanges());
            mapper.Setup(x => x.Map <CallViewModel>(updatedCall))
            .Returns(updatedCallViewModel);

            var response = callServices.UpdateCallPrice(data);

            Assert.NotNull(response);
        }
Ejemplo n.º 2
0
        public async Task Should_Return_404_Status_Code_If_Call_Not_Exist()
        {
            var data = CallViewModelFaker.GenerateCallViewModel();

            data.FromAreaCode = 1;
            data.ToAreaCode   = 28;

            var response = await factory.PerformRequest(client, action, route, data);

            Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
        }
Ejemplo n.º 3
0
        public async Task Should_Return_200_Status_Code_If_Call_Price_Updated()
        {
            var data = CallViewModelFaker.GenerateCallViewModel();

            data.FromAreaCode = 68;
            data.ToAreaCode   = 82;

            var response = await factory.PerformRequest(client, action, route, data);

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
        }
Ejemplo n.º 4
0
        public void Should_Not_Update_If_Call_Not_Exist()
        {
            var data = CallViewModelFaker.GenerateCallViewModel();

            callsRepository.Setup(x =>
                                  x.FindByFromToAreaCode(data.FromAreaCode, data.ToAreaCode)
                                  ).Returns((Call)null);

            Assert.Throws <FaleMaisException>(
                () => callServices.UpdateCallPrice(data)
                );
        }
Ejemplo n.º 5
0
        public void Should_Return_A_Call_Price()
        {
            var call = CallFaker.GenerateCall();

            var callViewModel = CallViewModelFaker.GenerateCallViewModel(call);

            var fromAreaCode = call.FromAreaCode;
            var toAreaCode   = call.ToAreaCode;

            callsRepository.Setup(x => x.FindByFromToAreaCode(fromAreaCode, toAreaCode))
            .Returns(call);
            mapper.Setup(x => x.Map <CallViewModel>(call)).Returns(callViewModel);

            var response = callServices.GetCallPriceFromTo(fromAreaCode, toAreaCode);

            Assert.NotNull(response);
        }
Ejemplo n.º 6
0
        public void Should_Return_200_Status_Code_If_Call_Call_Updated()
        {
            var data = CallViewModelFaker.GenerateCallViewModel();

            var updated = data;

            updated.PricePerMinute = data.PricePerMinute - 0.50m;

            callServices.Setup(x => x.UpdateCallPrice(data)).Returns(updated);

            var response = callsController.Update(callServices.Object, data);

            var actionResult = Assert.IsType <OkObjectResult>(response.Result);
            var actionValue  = Assert.IsType <CallViewModel>(actionResult.Value);

            Assert.NotNull(actionResult);
            Assert.Equal(StatusCodes.Status200OK, actionResult.StatusCode);
        }
Ejemplo n.º 7
0
        public void Should_Return_200_Status_Code_If_Query_Values_Valid()
        {
            var rnd = new Random();

            var call = CallViewModelFaker.GenerateCallViewModel();

            byte fromAreaCode = (byte)rnd.Next(1, 101);
            byte toAreaCode   = (byte)rnd.Next(1, 101);

            callServices.Setup(x => x.GetCallPriceFromTo(fromAreaCode, toAreaCode))
            .Returns(call);

            var response = callsController.GetPrice(
                callServices.Object,
                fromAreaCode,
                toAreaCode
                );

            var actionResult = Assert.IsType <OkObjectResult>(response.Result);
            var actionValue  = Assert.IsType <CallViewModel>(actionResult.Value);

            Assert.NotNull(actionResult);
            Assert.Equal(StatusCodes.Status200OK, actionResult.StatusCode);
        }