コード例 #1
0
        public void Create()
        {
            var toCreate = new TimeEntry(222, 333, Convert.ToDateTime("01/08/2008 12:00:01"), 24);
            var expected = new TimeEntry(1, 222, 333, Convert.ToDateTime("01/08/2008 12:00:01"), 24);

            _repository.Setup(r => r.Create(toCreate)).Returns(expected);

            var response = _controller.Create(toCreate) as CreatedAtRouteResult;

            Assert.Equal(201, response.StatusCode);
            Assert.Equal("GetTimeEntry", response.RouteName);
            Assert.Equal(expected, response.Value);
            _operationCounter.Verify(oc => oc.Increment(TrackedOperation.Create), Once);
        }
コード例 #2
0
        public void Create()
        {
            var toCreate = new TimeEntry(222, 333, new DateTime(2008, 08, 01, 12, 00, 01), 24);
            var expected = new TimeEntry(1, 222, 333, new DateTime(2008, 08, 01, 12, 00, 01), 24);

            _repository.Setup(r => r.Create(toCreate)).Returns(expected);

            var response = _controller.Create(toCreate);

            Assert.IsType <CreatedAtRouteResult>(response);

            var typedResponse = response as CreatedAtRouteResult;

            Assert.Equal(201, typedResponse.StatusCode);
            Assert.Equal("GetTimeEntry", typedResponse.RouteName);
            Assert.Equal(expected, typedResponse.Value);
        }
コード例 #3
0
        public void Create()
        {
            var toCreate = new TimeEntry(222, 333, new DateTime(2008, 08, 01, 12, 00, 01), 24);
            var expected = new TimeEntry(1, 222, 333, new DateTime(2008, 08, 01, 12, 00, 01), 24);

            _repository.Setup(r => r.Create(toCreate)).Returns(expected);

            var response = _controller.Create(toCreate);

            Assert.IsType <CreatedAtRouteResult>(response);

            var typedResponse = response as CreatedAtRouteResult;

            Assert.Equal(201, typedResponse.StatusCode);
            Assert.Equal("GetTimeEntry", typedResponse.RouteName);
            Assert.Equal(expected, typedResponse.Value);

            _operationCounter.Verify(oc => oc.Increment(TrackedOperation.Create), Times.Once());
        }