Exemplo n.º 1
0
        // 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 void Create_calls_add_and_save()
        {
            var mockSet = new Mock<IDbSet<Gutachter>>();
            var mockedContext = new Mock<IDashboardContext>();
            mockedContext.Setup(x => x.Gutachter).Returns(mockSet.Object);
            _sut = new GutachterRepository(mockedContext.Object);

            _sut.Create("Hans", "Hanson", "*****@*****.**");

            mockSet.Verify(x => x.Add((It.IsAny<Gutachter>())), Times.Once());
            mockedContext.Verify(x => x.SaveChanges(), Times.Once());
        }
Exemplo n.º 3
0
        public void Create_calls_add_and_save()
        {
            var mockSet       = new Mock <IDbSet <Gutachter> >();
            var mockedContext = new Mock <IDashboardContext>();

            mockedContext.Setup(x => x.Gutachter).Returns(mockSet.Object);
            _sut = new GutachterRepository(mockedContext.Object);

            _sut.Create("Hans", "Hanson", "*****@*****.**");

            mockSet.Verify(x => x.Add((It.IsAny <Gutachter>())), Times.Once());
            mockedContext.Verify(x => x.SaveChanges(), Times.Once());
        }
Exemplo n.º 4
0
        public void Create_adds_an_item_to_db()
        {
            _sut.Create("Hans", "Hanson", "*****@*****.**");

            Assert.That(_inMemoryDbSet.Count(), Is.EqualTo(4), "Create should add an item to DB");
        }