Exemplo n.º 1
0
        public void UpdateLayoutSuccess()
        {
            //Arrange
            var layoutRepository = new LayoutRepository(_container);
            var dbContext        = _serviceProvider.GetRequiredService <DeviserDbContext>();
            var layouts          = TestDataRepository.GetLayouts();

            foreach (var item in layouts)
            {
                layoutRepository.CreateLayout(item);
            }

            var layoutToUpdate = layoutRepository.GetLayouts().First();

            //Act
            layoutToUpdate.IsDeleted = true;
            layoutToUpdate.Name      = "NewName";
            layoutToUpdate.Config    = "[{\"Id\":\"0fcf04a2 - 3d71 - 26b0 - c371 - 6d936c6c65d8\",\"Type\":\"container\",\"LayoutTemplate\":\"container\"]";

            var result = layoutRepository.UpdateLayout(layoutToUpdate);

            //Assert
            Assert.NotNull(result);
            Assert.True(result.Name == layoutToUpdate.Name);
            Assert.True(result.Config == layoutToUpdate.Config);
            Assert.True(result.IsDeleted == layoutToUpdate.IsDeleted);

            //Clean
            dbContext.Layout.RemoveRange(dbContext.Layout);
        }
Exemplo n.º 2
0
        public void UpdateLayoutFail()
        {
            //Arrange
            var layoutRepository = new LayoutRepository(_container);
            var dbContext        = _serviceProvider.GetRequiredService <DeviserDbContext>();
            var layouts          = TestDataRepository.GetLayouts();

            foreach (var item in layouts)
            {
                layoutRepository.CreateLayout(item);
            }

            Layout layoutToUpdate = null;

            //Act
            var result = layoutRepository.UpdateLayout(layoutToUpdate);

            //Assert
            Assert.Null(result);

            //Clean
            dbContext.Layout.RemoveRange(dbContext.Layout);
        }