public void Read_returns_specific_item() { Gutachter result = _sut.Read(2); Assert.That(result.Id, Is.EqualTo(2)); Assert.That(result.Vorname, Is.EqualTo("Klaus")); }
public void Delete_removes_one_item_from_db() { _sut.Delete(2); Gutachter vorherKlaus = _inMemoryDbSet.FirstOrDefault(x => x.Id == 2); Assert.That(vorherKlaus, Is.EqualTo(null), "The specified item must be deleted from DB"); _mockedContext.Verify(x => x.SaveChanges(), Times.Once()); }
// POST api/values public HttpResponseMessage Post(Gutachter gutachter) { var newId = _repository.Create(gutachter.Vorname, gutachter.Nachname, gutachter.EMail); return(Request.CreateResponse(HttpStatusCode.Created, "{ Id: " + newId + ", " + " '_links': {" + " 'self': { 'href': '/api/Gutachter/'" + newId + " }" + "}")); }
public ActionResult Index() { ViewBag.Title = "Home Page"; Gutachter gutachter = _repository.Read(1); return(View( new { Gutachter = gutachter, HelloWorld = "Hello World" }.ToExpando() )); }
public void Update_modifies_item_in_db() { var changedData = new Gutachter { Id = 2, Nachname = "TEST", Vorname = "TEST", EMail = "*****@*****.**" }; _sut.Update(changedData); Gutachter vorherKlaus = _inMemoryDbSet.First(x => x.Id == 2); Assert.That(vorherKlaus.Vorname, Is.EqualTo(changedData.Vorname), "Vorname should change"); Assert.That(vorherKlaus.Nachname, Is.EqualTo(changedData.Nachname), "Nachname should change"); Assert.That(vorherKlaus.EMail, Is.EqualTo(changedData.EMail), "EMail should change"); Assert.That(vorherKlaus.Gutachten.Count, Is.EqualTo(1), "Gutachten should not be changed"); _mockedContext.Verify(x => x.SaveChanges(), Times.Once()); }
public void Init() { var klaus = new Gutachter { Id = 2, Vorname = "Klaus" }; klaus.Gutachten.Add(new Gutachten()); _inMemoryDbSet = new InMemoryDbSet <Gutachter>(true) { new Gutachter { Id = 1, Vorname = "Hans" }, klaus, new Gutachter { Id = 3, Vorname = "Inge" } }; _mockedContext = new Mock <IDashboardContext>(); _mockedContext.Setup(x => x.Gutachter).Returns(_inMemoryDbSet); _sut = new GutachterRepository(_mockedContext.Object); }
// PUT api/values/5 public void Put(Gutachter gutachter) { _repository.Update(gutachter); }