コード例 #1
0
        public async Task TestErrGetArticoloByCode()
        {
            string CodArt = "0009926010";

            // Arrange
            var dbContext  = DbContextMocker.nanshopDbContext();
            var controller = new ArticoliController(new ArticoliStore(dbContext), MapperMocker.GetMapper());

            // Act
            var response = await controller.GetArticoloByCodice(CodArt) as ObjectResult;

            var value = response.Value as ArticoliDTO;

            dbContext.Dispose();

            // Assert
            Assert.Equal(404, response.StatusCode);
            Assert.Null(value);
            Assert.Equal("Non è stato trovato l'articolo con codice '0009926010'", response.Value);
        }
コード例 #2
0
        public async Task TestGetArticoloByCodice()
        {
            string codArt = "000992601";

            //arrange
            var dbContext  = DbContextMocker.nanshopDbContext();
            var controller = new ArticoliController(new ArticoliStore(dbContext), MapperMocker.GetMapper());

            // Act
            var response = await controller.GetArticoloByCodice(codArt) as ObjectResult;

            var value = response.Value as ArticoliDTO;

            dbContext.Dispose();

            // Assert
            Assert.Equal(200, response.StatusCode);
            Assert.NotNull(value);
            Assert.Equal(codArt, value.CodArt);
        }