Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 2
0
        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));
        }