public void Add_SavesDocumentToSession() { Mock <IDocumentSession> documentSessionMock = new Mock <IDocumentSession>(); DummyRepository repository = new DummyRepository(documentSessionMock.Object); DummyDocument innerDoc = new DummyDocument(); DummyEntity entity = new DummyEntity(innerDoc); repository.Add(entity); documentSessionMock.Verify(x => x.Store(innerDoc), Times.Once()); }
public IActionResult Post([FromBody] DummyModel item) { if (!ModelState.IsValid) { return(BadRequest()); } var result = _repo.Add(item); if (result is AlreadyExistsError err) { return(Forbid(err.Message)); } return(StatusCode(201)); }