コード例 #1
0
        public async Task TestErrSelArticoloByEan()
        {
            string Ean = "80582533A";

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

            // Act
            var response = await controller.GetArticoloByEan(Ean) 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 ean '80582533A'", response.Value);
        }
コード例 #2
0
        public async Task TestSelArticoloByEan()
        { // System.InvalidCastException : Unable to cast object of type 'System.Int16' to type 'System.Int32'.
            string Ean = "80582533";

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

            // Act
            var response = await controller.GetArticoloByEan(Ean) as ObjectResult;

            var value = response.Value as ArticoliDTO;

            dbContext.Dispose();

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