Exemple #1
0
        public void AddNewTape_TestIfTapeIsAdded()
        {
            // arrange
            var tapeInput = new TapeInputModel
            {
                Title        = "Bad Taste",
                DirectorName = "Peter Jackson",
                Eidr         = "2",
                ReleaseDate  = new DateTime(1999, 10, 10),
                Type         = "VHS"
            };

            _tapeRepositoryMock.Setup(method => method.AddNewTape(tapeInput)).Returns(
                FizzWare.NBuilder.Builder <TapeDetailsDto>
                .CreateNew().With(x => x.Id = 1).With(x => x.Eidr = "1").With(x => x.Title = "Pulp Fiction")
                .With(x => x.Type           = "VHS").With(x => x.AverageRating = 2.2)
                .With(x => x.DirectorName   = "Quentin Tarantino")
                .With(x => x.ReleaseDate    = DateTime.Today).Build());

            // act
            var newtape = _tapeService.AddNewTape(tapeInput);

            // assert
            Assert.AreEqual("VHS", newtape.Type);
            Assert.IsNotNull(newtape);
        }
Exemple #2
0
        public IActionResult AddNewTape([FromBody] TapeInputModel tape)
        {
            if (!ModelState.IsValid)
            {
                throw new ModelFormatException();
            }

            return(StatusCode(201, _tapeService.AddNewTape(tape)));
        }