示例#1
0
        public void GetLayoutSuccess()
        {
            //Arrange
            var layoutRepository = new LayoutRepository(_container);
            var dbContext        = _serviceProvider.GetRequiredService <DeviserDbContext>();
            var layouts          = TestDataRepository.GetLayouts();

            foreach (var item in layouts)
            {
                layoutRepository.CreateLayout(item);
            }
            var id = layouts.First().Id;

            //Act
            var result = layoutRepository.GetLayout(id);

            //Assert
            Assert.NotNull(result);
            Assert.NotEqual(result.Id, Guid.Empty);
            Assert.True(!string.IsNullOrEmpty(result.Name));
            Assert.True(!string.IsNullOrEmpty(result.Config));

            //Clean
            dbContext.Layout.RemoveRange(dbContext.Layout);
        }
示例#2
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);
        }
示例#3
0
        public void CreateLayoutFail()
        {
            //Arrange
            var    layoutRepository = new LayoutRepository(_container);
            Layout layout           = null;

            //Act
            var result = layoutRepository.CreateLayout(layout);

            //Assert
            Assert.Null(result);
        }
示例#4
0
        public void CreateLayoutSuccess()
        {
            //Arrange
            var layoutRepository = new LayoutRepository(_container);
            var layouts          = TestDataRepository.GetLayouts();
            var layout           = layouts.First();

            //Act
            var result = layoutRepository.CreateLayout(layout);

            //Assert
            Assert.NotNull(result);
            Assert.NotEqual(result.Id, Guid.Empty);
            Assert.False(result.IsDeleted);
            Assert.True(!string.IsNullOrEmpty(result.Config));
            Assert.True(!string.IsNullOrEmpty(result.Name));
        }
示例#5
0
        public void GetLayoutsSuccess()
        {
            //Arrange
            var layoutRepository = new LayoutRepository(_container);
            var dbContext        = _serviceProvider.GetRequiredService <DeviserDbContext>();
            var layouts          = TestDataRepository.GetLayouts();

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

            //Act
            var result = layoutRepository.GetLayouts();

            //Assert
            Assert.NotNull(result);
            Assert.True(result.Count > 0);

            //Clean
            dbContext.Layout.RemoveRange(dbContext.Layout);
        }
示例#6
0
        public void GetLayoutFail()
        {
            //Arrange
            var layoutRepository = new LayoutRepository(_container);
            var dbContext        = _serviceProvider.GetRequiredService <DeviserDbContext>();
            var layouts          = TestDataRepository.GetLayouts();

            foreach (var item in layouts)
            {
                layoutRepository.CreateLayout(item);
            }
            var id = Guid.Empty;

            //Act
            var result = layoutRepository.GetLayout(id);

            //Assert
            Assert.Null(result);

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