コード例 #1
0
        public async Task ReturnsNoContentWhenUpdateSuccessful()
        {
            var videoId = Guid.NewGuid();

            _session
            .ExecuteAsync(Arg.Is <DeleteVideoCommand>(c =>
                                                      c.VideoId == videoId))
            .Returns(1);

            var result = await _controller.Delete(videoId);

            Received.InOrder(() =>
            {
                _session.Received(1).ExecuteAsync(Arg.Any <DeleteVideoCommand>());
                _session.Received(1).Commit();
                _session.Received(1).Dispose();
            });
            result.Should().BeOfType <NoContentResult>();
        }
コード例 #2
0
        public async Task ReturnsNoContentWhenUpdateSuccessful()
        {
            var video = VideoBuilder.CreateVideo("Some Video").Build();

            _session
            .ExecuteAsync(Arg.Is <UpdateVideoCommand>(c =>
                                                      c.VideoId == video.VideoId &&
                                                      c.Details == video))
            .Returns(1);

            var result = await _controller.Put(video.VideoId, video);

            Received.InOrder(() =>
            {
                _session.Received(1).ExecuteAsync(Arg.Any <UpdateVideoCommand>());
                _session.Received(1).Commit();
                _session.Received(1).Dispose();
            });
            result.Should().BeOfType <NoContentResult>();
        }
コード例 #3
0
        public async Task ReturnsCreatedWhenModelStateValid()
        {
            var video = VideoBuilder.CreateVideo("Some Video").Build();

            var result = await _controller.Post(video);

            Received.InOrder(() =>
            {
                _session.Received(1).ExecuteAsync(Arg.Is <InsertVideoCommand>(c => c.Video == video));
                _session.Received(1).Commit();
                _session.Received(1).Dispose();
            });
            result.Should().BeOfType <CreatedAtActionResult>().Which
            .Should().BeEquivalentTo(new
            {
                ActionName  = nameof(VideosController.Get),
                RouteValues = new RouteValueDictionary {
                    { "videoId", video.VideoId }
                },
                Value = video
            });
        }