public Motherboard Update(Motherboard motherboard)
 {
     var entry = _context.Entry<Motherboard>(motherboard);
     entry.State = EntityState.Modified;
     _context.SaveChanges();
     return motherboard;
 }
 public void Should_Create_And_Save_A_Motherboard()
 {
     Motherboard motherboard = new Motherboard("Modelo DC", "DELL", TypeMotherboardEnum.Notebook);
     _repository.Create(motherboard);
     Motherboard motherboardTest = _context.Motherboards.Find(motherboard.Id);
     Assert.IsNotNull(motherboardTest);
 }
 public void Update_Motherboard_Service_Test()
 {
     Motherboard computer = new Motherboard("Model DC", "Intel", TypeMotherboardEnum.Notebook);
     IMotherboardService service = new MotherboardService(_mockRepository.Object, _mockPostRepository.Object);
     service.Update(computer);
     _mockRepository.Verify(repo => repo.Update(computer));
 }
 public Post Create(Motherboard computer)
 {
     _repository.Create(computer);
     // Ao cadastrar um computador, é criado um post no twitter
     Post post = new Post(computer);
     _postRepository.SaveOrUpdate(post);
     return post;
 }
 public void Should_Find_A_Motherboard()
 {
     // Create Motherboard
     Motherboard motherboard = new Motherboard("Modelo DC", "Intel", TypeMotherboardEnum.Notebook);
     _context.Motherboards.Add(motherboard);
     _context.SaveChanges();
     //Test
     Motherboard motherboardTest = _repository.Read(motherboard.Id);
     Assert.AreEqual(motherboard.Id, motherboardTest.Id);
 }
 public void Should_Find_All_Motherboards()
 {
     // Create Motherboard
     Motherboard motherboard = new Motherboard("Modelo DC", "Intel", TypeMotherboardEnum.Notebook);
     _context.Motherboards.Add(motherboard);
     _context.SaveChanges();
     //Test
     List<Motherboard> motherboardsListTest = _repository.ReadAll();
     Assert.AreEqual(1, motherboardsListTest.Count);
 }
 public void Should_Delete_A_Motherboard()
 {
     // Create Motherboard
     Motherboard motherboard = new Motherboard("Modelo DC", "DELL", TypeMotherboardEnum.Notebook);
     _context.Motherboards.Add(motherboard);
     _context.SaveChanges();
     // Delete with repository and update context
     _repository.Delete(motherboard);
     _context.Entry(motherboard).Reload();
     //Test
     Motherboard motherboardTest = _context.Motherboards.Find(motherboard.Id);
     Assert.IsNull(motherboardTest);
 }
 public Motherboard Update(Motherboard computer)
 {
     return _repository.Update(computer);
 }
 public void Delete(Motherboard computer)
 {
     _repository.Delete(computer);
 }
 public void Delete(Motherboard motherboard)
 {
     motherboard = _context.Motherboards.Find(motherboard.Id);
     _context.Motherboards.Remove(motherboard);
     _context.SaveChanges();
 }
 public void Create(Motherboard motherboard)
 {
     _context.Motherboards.Add(motherboard);
     _context.SaveChanges();
 }
 public void Should_Create_Motherboard_Valid()
 {
     Motherboard motherboard = new Motherboard("Model GC", "DELL", TypeMotherboardEnum.Notebook);
     Assert.AreEqual("Model GC: DELL", motherboard.ToString());
 }
 public void Should_Create_Motherboard_Invalid_Model()
 {
     Motherboard computer = new Motherboard(null, "DELL", TypeMotherboardEnum.Notebook);
 }
 public void Should_Create_Motherboard_Invalid_Brand()
 {
     Motherboard computer = new Motherboard("Model GC", null, TypeMotherboardEnum.Notebook);
 }
 public void Should_Update_A_Motherboard()
 {
     // Create Motherboard
     Motherboard motherboard = new Motherboard("Modelo DC", "Intel", TypeMotherboardEnum.Notebook);
     _context.Motherboards.Add(motherboard);
     _context.SaveChanges();
     // Delete with repository and update context
     motherboard.Model = "Model AB";
     _repository.Update(motherboard);
     _context.Entry(motherboard).Reload();
     //Test
     Motherboard motherboardTest = _context.Motherboards.Find(motherboard.Id);
     Assert.AreEqual("Model AB", motherboardTest.Model);
 }