public void FormatInputData_Receiving_Valid_Format() { // Arrange string inputData = "03/08/2018 3 5"; // Act PetShopInputViewModel petShopInput = _ProgramServices.FormatInputData(inputData); // Assert Assert.IsNull(petShopInput.ErrorMessage); }
public void FormatInputData_Receiving_Invalid_Format() { // Arrange string inputData = "2013Teste 3239"; // Act PetShopInputViewModel petShopInput = _ProgramServices.FormatInputData(inputData); // Assert Assert.IsNotNull(petShopInput.ErrorMessage); }
public void FormatInputData_Receiving_Empty_Value() { // Arrange string inputData = String.Empty; // Act PetShopInputViewModel petShopInput = _ProgramServices.FormatInputData(inputData); // Assert Assert.IsNotNull(petShopInput.ErrorMessage); }
public void GetBetterPetShop_VaiRex_Winner() { // Arrange string winnerPetShopName = "Vai Rex"; var petShopInput = new PetShopInputViewModel() { DateOfBath = DateTime.Parse("28/07/2019"), ErrorMessage = String.Empty, QuantitySmallDogs = 2, QuantityBigDogs = 1 }; // Act PetShopResponseViewModel petShopResponse = _petShopServices.GetBetterPetShop(petShopInput); // Assert Assert.AreEqual(petShopResponse.BestPetShopName, winnerPetShopName); }
public void GetBetterPetShop_MeuCaninoFeliz_Winner() { // Arrange string winnerPetShopName = "Meu Canino Feliz"; var petShopInput = new PetShopInputViewModel() { DateOfBath = DateTime.Parse("03/08/2018"), ErrorMessage = String.Empty, QuantitySmallDogs = 3, QuantityBigDogs = 5 }; // Act PetShopResponseViewModel petShopResponse = _petShopServices.GetBetterPetShop(petShopInput); // Assert Assert.AreEqual(petShopResponse.BestPetShopName, winnerPetShopName); }
static void Main(string[] args) { var petShopInput = new PetShopInputViewModel(); bool inputDataIsValid = true; do { Console.WriteLine("Digite os dados de entrada no formato, <data> <Quant Caes pequenos> <Quant Caes grandes>:"); petShopInput = _programServices.FormatInputData(Console.ReadLine()); inputDataIsValid = String.IsNullOrEmpty(petShopInput.ErrorMessage) ? true : false; } while (inputDataIsValid == false); var petShopResponse = _petShopService.GetBetterPetShop(petShopInput); Console.WriteLine($"Melhor Canil: {petShopResponse.BestPetShopName}"); Console.WriteLine($"Preço Total: {petShopResponse.TotalPriceDogBath}"); Console.ReadKey(); }
public PetShopResponseViewModel GetBetterPetShop(PetShopInputViewModel petShopInput) { var petShopResponseList = new List <PetShopResponseViewModel>(); var vaiRex = new VaiRex(15.0m, 50.0m, 1700); var meuCaninoFeliz = new MeuCaninoFeliz(20.0m, 40.0m, 2000); var chowChawGas = new ChowChawGas(30.0m, 45.0m, 800); PetShopResponseViewModel totalPriceVaiRexPetShop = vaiRex.GetTotalPrice(petShopInput.QuantitySmallDogs, petShopInput.QuantityBigDogs, petShopInput.DateOfBath); PetShopResponseViewModel totalPriceMeuCaninoFelizPetShop = meuCaninoFeliz.GetTotalPrice(petShopInput.QuantitySmallDogs, petShopInput.QuantityBigDogs, petShopInput.DateOfBath); PetShopResponseViewModel totalPriceChowChawGasPetShop = chowChawGas.GetTotalPrice(petShopInput.QuantitySmallDogs, petShopInput.QuantityBigDogs, petShopInput.DateOfBath); petShopResponseList.Add(totalPriceVaiRexPetShop); petShopResponseList.Add(totalPriceMeuCaninoFelizPetShop); petShopResponseList.Add(totalPriceChowChawGasPetShop); return(petShopResponseList.OrderBy(p => p.TotalPriceDogBath).ThenBy(p => p.DogKennelDistanceMetre).FirstOrDefault()); }
public PetShopInputViewModel FormatInputData(string inputData) { string[] data = inputData.Split(' '); try { var petShopInput = new PetShopInputViewModel() { DateOfBath = Convert.ToDateTime(data[0]), QuantitySmallDogs = Convert.ToInt32(data[1]), QuantityBigDogs = Convert.ToInt32(data[2]) }; return(petShopInput); } catch (Exception e) { return(new PetShopInputViewModel() { ErrorMessage = e.Message }); } }