public void Update() { var unitOfWork = new GameUnitOfWork(); var service = new GameDomainService(unitOfWork); var game = new Game() { Name = "Test", Price = 100, Category = GameCategory.RPG }; service.Insert(game); unitOfWork.Commit(); game.Name = "Modfied"; service.Update(game); unitOfWork.Commit(); //Deve haver ao menos 1 game que o nome inicie com Mod Assert.IsTrue(service.FindByName("Mod").Count > 0); }
public void Delete() { var unitOfWork = new GameUnitOfWork(); var service = new GameDomainService(unitOfWork); var game = new Game() { Name = "Delete", Price = 100, Category = GameCategory.RPG }; service.Insert(game); unitOfWork.Commit(); //Deve haver 1 registro (adicionado acima) Assert.IsTrue(service.FindByName("Delet").Count > 0); service.Delete(game); unitOfWork.Commit(); //Nao deve haver registros Assert.IsTrue(service.FindByName("Delet").Count == 0); }
public void Delete() { Console.Clear(); var unitOfWork = new GameUnitOfWork(); var service = new GameDomainService(unitOfWork); var game = Find(); if (game == null) { Console.WriteLine("Nenhum registro encontrado!"); return; } service.Delete(game); unitOfWork.Commit(); }
public void Update() { Console.Clear(); var unitOfWork = new GameUnitOfWork(); var service = new GameDomainService(unitOfWork); var game = Find(); if (game == null) { Console.WriteLine("Nenhum registro encontrado!"); return; } Console.WriteLine("Digite o nome >"); game.Name = Console.ReadLine(); try { Console.WriteLine("Diite o preco >"); game.Price = Convert.ToDouble(Console.ReadLine(), System.Globalization.CultureInfo.InvariantCulture); } catch (Exception e) { Console.WriteLine("O campo preço aceita somente numeros. Operação abortada, tente novamente! >>> " + e.Message); return; } game.Category = Category(); game.Available = Availabe(); service.Update(game); unitOfWork.Commit(); }
public void Insert() { Console.Clear(); var unitOfWork = new GameUnitOfWork(); var service = new GameDomainService(unitOfWork); Console.WriteLine("Digite o nome >"); string name = Console.ReadLine(); double price; try { Console.WriteLine("Diite o preco >"); price = Convert.ToDouble(Console.ReadLine(), System.Globalization.CultureInfo.InvariantCulture); } catch (Exception e) { Console.WriteLine("O campo preço aceita somente numeros. Operação abortada, tente novamente! >>>" + e.Message); return; } var game = new Game() { Name = name, Price = price, Category = Category() }; service.Insert(game); unitOfWork.Commit(); }