public void Create_OK() { //Arrange Create.PrepararArchivo(); // Act var service = new PetServices(); // Assert var actual = service.Create("DOG,Pelusa,F", "PetsTest"); Assert.True(actual.Data); }
public void Create_Error_Wrong_Gender() { //Arrange Create.PrepararArchivo(); // Act var service = new PetServices(); // Assert var actual = service.Create("DOG,Pelusa,Test", "PetsTest"); Assert.NotNull(actual.Errors); Assert.Contains(string.Format(PetsStrings.ErrorWrongGender, "\n"), actual.Errors.First()); }
public void Create_Error_Required_Fild() { //Arrange Create.PrepararArchivo(); // Act var service = new PetServices(); // Assert var actual = service.Create(",,", "PetsTest"); Assert.NotNull(actual.Errors); Assert.Contains(string.Format(PetsStrings.ErrorRequiredFild, "\n"), actual.Errors.First()); }
static void Main(string[] args) { Console.Title = PetsStrings.Title; Console.WriteLine(Console.Title + "\n"); var response = ""; while (response != "4") { var result = _petService.GetAll(FILE); Console.WriteLine(result.Data.ToMarkdownTable() + "\n"); Console.WriteLine(PetsStrings.TextMenu, "\n"); response = Console.ReadLine(); int number; var test = int.TryParse(response, out number); if (test == false) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(PetsStrings.ErrorNoNumber, "\n"); Console.ResetColor(); } #region Search if (number == 1) { Console.WriteLine(PetsStrings.TextSearch, "\n"); response = Console.ReadLine(); var res = _petService.Search(response, FILE); if (res.Errors.Any()) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(res.Errors.First()); Console.ResetColor(); } else { Console.WriteLine(res.Data.ToMarkdownTable() + "\n"); } } #endregion #region Create if (number == 2) { Console.WriteLine(PetsStrings.TextCreate, "\n"); var pet = Console.ReadLine(); var res = _petService.Create(pet, FILE); if (res.Errors.Any()) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(res.Errors.First()); Console.ResetColor(); } else { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(PetsStrings.MessageOk, "\n"); Console.ResetColor(); } } #endregion #region Delete if (number == 3) { Console.WriteLine(PetsStrings.TextDelete, "\n"); var id = Console.ReadLine(); var res = _petService.Delete(id, FILE); if (res.Errors.Any()) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(res.Errors.First()); Console.ResetColor(); } else { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(PetsStrings.MessageOk, "\n"); Console.ResetColor(); } } #endregion #region Exit if (number == 4) { return; } #endregion } }