Ejemplo n.º 1
0
        public async Task TestSelArticoliByDescrizione()
        { // System.NullReferenceException : Object reference not set to an instance of an object.
            string Descrizione = "ACQUA ROCCHETTA";

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

            // Act
            var actionResult = await controller.GetArticoliByDesc(Descrizione, "");

            dbContext.Dispose();

            var result = actionResult.Result as ObjectResult;
            var value  = result.Value as ICollection <ArticoliDTO>;



            // Assert
            Assert.Equal(200, result.StatusCode);
            Assert.NotNull(value);
            Assert.Equal(3, value.Count);
            Assert.Equal("002001201", value.FirstOrDefault().CodArt);
        }